Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
damien opened this issue Feb 15, 2011 · 1 comment
Open

Comments

@damien
Copy link

damien commented Feb 15, 2011

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.

@damien
Copy link
Author

damien commented Feb 15, 2011

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant