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

Check for negative millisecond offset #171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,11 @@ else if ( isDirectory )
}
}

targetFileName.setLastModified( entryDate.getTime() );
final long millis = entryDate.getTime();
if ( millis >= 0 )
{
targetFileName.setLastModified( millis );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find setLastModified behavior strange because lastModified works perfectly fine with negative values (dates before 1970-01-01). We can use Files.setLastModifiedTime, which works with negative values[1], and use null for missing date. Some archives, such as tar, support negative values so it should be up to the specific UnArchiver implementation to decide if the date is known or not.

[1] Whether the underlying file system supports it is different question. Unfortunately the behavior is unspecified if the date is out of range for the file system. Maybe we can just catch the exception so failure to set the date does not fail the file extraction?

}

if ( !isIgnorePermissions() && mode != null && !isDirectory )
{
Expand Down