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

Add fixedEntryModificationTime attribute to AbstractZipArchiver #49

Closed
wants to merge 1 commit into from

Conversation

danielwegener
Copy link

... to override zipEntry times globally. closes #48

zipEntry.setTime( lastModified + ( isJava7OrLower ? 1999 : 0 ) );

if (fixedEntryModificationTime != null) {
zipEntry.setTime(Math.max(MIN_MS_DOS_TIME, fixedEntryModificationTime));
Copy link
Author

Choose a reason for hiding this comment

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

Lower values like 0L produce weird Dates when reading (seen something like 8. Nov 1979, which normally cannot be expressed by MS-DOS time). Not sure if we should do the round-up here.

return fixedEntryModificationTime;
}

public void setFixedEntryModificationTime(Long fixedEntryModificationTime) {
Copy link
Member

Choose a reason for hiding this comment

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

I really think this should be some kind of Date object, not a long. I am also contemplating if this setter should be on AbstractArchiver, others could just throw UnsupportedOepratiionException

Copy link
Member

Choose a reason for hiding this comment

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

Actually wouldn't it be even better if it works the same way as forced file/dir modes? I mean they are logically related - forced file/dir modes are options to override the file permissions. This is option to override the last modified date.

Copy link
Author

Choose a reason for hiding this comment

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

Summarizing:

  • a method setModificationTime(Date modificationTime) (+getter) on Archiver
  • a field private Date forcedModificationTime = null on AbstractArchiver
  • The field is only used by TarArchiver, AbstractZipArchiver and DirArchiver. Other implementations would just ignore it (like with filemode)
  • Question then: do we also need overloaded methods for addFile/addResource to allow overriding the modificationTime on an entry basis (and having a modificationTime field in ArchiveEntry)?

Copy link
Member

@krosenvold krosenvold Jul 8, 2016

Choose a reason for hiding this comment

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

It seems to me like ArchiveEntry needs modifcationTime with that is overridden much the same way as the "mode" field. As for per-entry modifiers I suggest you only add the ones you need for the patch. So please do like @plamentotev suggests

@michael-o
Copy link
Member

Pre-Java 7 is gone, please re-evaluate this issue.

@danielwegener
Copy link
Author

@michael-o I can spontaniously not see why this issue should be pre-java 7 related. Can you help me out? :)

@plamentotev
Copy link
Member

@danielwegener

@michael-o I can spontaniously not see why this issue should be pre-java 7 related. Can you help me out? :)

zipEntry.setTime( lastModified + ( isJava7OrLower ? 1999 : 0 ) );

Now Java 7 is the minimum require version so isJava7OrLower was deleted.

@michael-o
Copy link
Member

@danielwegener For instance stuff like isJava7OrLower.
@plamentotev On the second thought, this is less or equal than. This still might be necessary with Java 7+, isn't it?

@plamentotev
Copy link
Member

plamentotev commented May 26, 2017 via email

@plamentotev
Copy link
Member

plamentotev commented May 26, 2017 via email

@hboutemy
Copy link
Member

job done in #118

@hboutemy hboutemy closed this Aug 16, 2019
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

Successfully merging this pull request may close these issues.

Add ability to NOT write timestamps for zip file entries
5 participants