Sha256: 169d89fdbe8e107899a1238fd263670f76a1369c53e2c368469a27d08d1cddfd

Contents?: true

Size: 798 Bytes

Versions: 4

Compression:

Stored size: 798 Bytes

Contents

module Bcms
  module WebDAV

    # Inherits from Rack File in order to change where paths are looked up from, since the
    # public path of CMS files is different that actual file path.
    class File < Rack::File

      # This should be an absolute file path
      def initialize(absolute_file_path)
        @path = absolute_file_path
      end

      # Don't look up from PATH, look up from passed in variable
      def _call(env)
        Rails.logger.debug "Starting to serve file @ path #{@path}"

        # From here down is a copy&paste of Rack::File#_call
        begin
          if F.file?(@path) && F.readable?(@path)
            serving
          else
            raise Errno::EPERM
          end
        rescue SystemCallError
          not_found
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bcms_webdav-1.0.4 lib/bcms_webdav/file.rb
bcms_webdav-1.0.2 lib/bcms_webdav/file.rb
bcms_webdav-1.0.1 lib/bcms_webdav/file.rb
bcms_webdav-1.0.0 lib/bcms_webdav/file.rb