Skip to content

Sinatra Cache errors and crashes Sinatra when writing cache files #6

@damien

Description

@damien

I'm running into errors on a production environment with Sinatra Cache that occur when it attempts to write cache file under the following conditions:

  • I have configured Sinatra Cache to use .cache as the cache file extension
  • The request path is /user/bh_moving.com
  • There is a directory of the same name in ./tmp/cache/user/bh_moving.com/
  • The directory bh_moving.com/ contains a single file: index.cache
  • Sinatra Cache attempts and fails to write the cache file to ./tmp/cache/user/bh_moving.com

This all results in the following error message:

ERROR: Is a directory -  /some_path_i_scrubbed_from_this_stacktrace/tmp/cache/user/bh_moving.com

The stacktrace:

/gems/sinatra-cache-0.3.6/lib/sinatra/cache/helpers.rb:558:in `initialize'
/gems/sinatra-cache-0.3.6/lib/sinatra/cache/helpers.rb:558:in `open'
/gems/sinatra-cache-0.3.6/lib/sinatra/cache/helpers.rb:558:in `cache_write_file'
/gems/sinatra-cache-0.3.6/lib/sinatra/templates.rb:56:in `render'
/gems/sinatra-1.1.2/lib/sinatra/base.rb:390:in `haml'
/some_path_i_scrubbed_from_this_stacktrace/app/lib/jelli/ui.rb:732:in `block in <class:UI>'
/gems/sinatra-1.1.2/lib/sinatra/base.rb:802:in `instance_eval'
/gems/sinatra-1.1.2/lib/sinatra/base.rb:802:in `block in error_block!'
/gems/sinatra-1.1.2/lib/sinatra/base.rb:797:in `each'
/gems/sinatra-1.1.2/lib/sinatra/base.rb:797:in `error_block!'
/gems/sinatra-1.1.2/lib/sinatra/base.rb:791:in `handle_exception!'

I suspect the issue is caused by either the presence of a dot in the path/cache file name or by the fact that the name of the cache file without it's extension is identical to that of the directory.

I'm strapped for time, so or now I'm going to disable caching for the path that's causing errors in my application. However, I am happy to help hunt down any other information needed to verify that this is a bug or find any underlying issues.

Thanks in advance for any assistance offered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions