Skip to content

File.mtime doesn't return a useful value for a file in a jar #3812

Description

@bigsur0

Symptom

Sinatra AssetPack fails to get a valid Last-Modified time from an asset packaged in a JAR causing upstream processing by Rack::Deflater to fail.

Environment

jruby-9.0.3.0
Linux & Mac (when running from a jar archive)
Using Sinatra, Sinatra AssetPack, and Rack::Deflater

Expected Behavior

When Rack goes to read the static asset from the jar file via the classpath: scheme it should provide a File object that returns useful Time object for File.mtime, so that when the Last-Modified header is read and parsed upstream processing w/ Rack::Deflater it can appropriately parse the Time string.

Actual Behavior

It throws an ArgumentError @: https://github.com/headius/jruby/blob/master/lib/ruby/2.0/time.rb#L505

Another useful line just above the previous link in the stack : https://github.com/rack/rack/blob/master/lib/rack/deflater.rb#L58

What should File.mtime return for a file in a jar? The modified time for the file or at a minimum the modified time for the jar? Here's an example.

$ java -jar jruby-complete-9.0.3.0.jar -e 'load "META-INF/jruby.home/bin/jirb"'
>> File.exists?("classpath:META-INF/jruby.home/bin/jirb")
=> true
>> File.mtime("classpath:META-INF/jruby.home/bin/jirb")
=> 1969-12-31 16:00:00 -0800
>> File.mtime("classpath:META-INF/jruby.home/bin")
=> 1969-12-31 16:00:00 -0800

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions