kematzy / sinatra-cache

A Sinatra Extension that makes Page and Fragment Caching easy
MIT License
161 stars 21 forks source link

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

Open damien opened 13 years ago

damien commented 13 years ago

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:

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.

damien commented 13 years ago

Update: I've verified this only happens on paths with a dot in them. To reproduce:

  1. Enable Sinatra Cache
  2. Visit a path with a trailing slash and a dot in the name of the last directory; eg: /user/test.user/
  3. Access the same path without the trailing slash; eg: /user/test.user