diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-09-04 11:26:27 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-09-04 11:26:27 -0700 |
commit | 1bb4deecf57332b290c5a6994d4ff885c42e9054 (patch) | |
tree | 061f67390832a8f19482290cb6992eeec1fae5bd | |
parent | 5d4dcd3b8c7538c19794592aba04bb91e868a5d4 (diff) | |
download | rack-1bb4deecf57332b290c5a6994d4ff885c42e9054.tar.gz |
remove a few more instance variables
-rw-r--r-- | lib/rack/directory.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/rack/directory.rb b/lib/rack/directory.rb index 195cbf3f..dbf05d1e 100644 --- a/lib/rack/directory.rb +++ b/lib/rack/directory.rb @@ -59,7 +59,7 @@ table { width:100%%; } forbidden else @path = ::File.join(@root, path_info) - list_path(env, path_info) + list_path(env, @path, path_info) end end @@ -73,9 +73,9 @@ table { width:100%%; } "X-Cascade" => "pass"}, [body]] end - def list_directory(path_info) + def list_directory(path_info, path) @files = [['../','Parent Directory','','','']] - glob = ::File.join(@path, '*') + glob = ::File.join(path, '*') url_head = (@script_name.split('/') + path_info.split('/')).map do |part| Rack::Utils.escape part @@ -109,12 +109,12 @@ table { width:100%%; } # TODO: add correct response if not readable, not sure if 404 is the best # option - def list_path(env, path_info) - @stat = ::File.stat(@path) + def list_path(env, path, path_info) + stat = ::File.stat(path) - if @stat.readable? - return @app.call(env) if @stat.file? - return list_directory(path_info) if @stat.directory? + if stat.readable? + return @app.call(env) if stat.file? + return list_directory(path_info, path) if stat.directory? else raise Errno::ENOENT, 'No such file or directory' end |