Hello,
I'm using Apache Commons Compress version 1.27.0 to create a zip archive
and running into a problem when I set the creation, last modified and last
access times of the ZipArchiveEntry objects. As I iterate over the files to
add to the ZipArchiveOutputStream I set all three times to the same value
like this:

...
final FileTime time = FileTime.fromMillis(timeInMilliseconds);
final ZipArchiveOutputStream zip = new ZipArchiveOutputStream(os));
final ZipArchiveEntry entry = zip.createArchiveEntry(file, name);
entry.setCreationTime(time);
entry.setLastModifiedTime(time);
entry.setLastAccessTime(time);
zip.putArchiveEntry(entry);
...

But when I open the zip archive after it has been created, not every file
has the same times for those metadata fields. For example, all of the XML
files in the zip archive have correctly set creation, last modified and
last access times. The same is true with directories. But all other files
in the archive, whether they are plain text or images or any other mime
type, only have the correct creation and last modified times. None of them
have the correct last access time.

I cannot figure out why the setLastAccessTime() method works for one
particular type of file but not any others. Has anyone else experienced
this issue? Is there a solution that I'm missing? Thank you in advance for
any information you can provide.


Thanks,
Nick W.


---
Senior Software Engineer
Texas Digital Library

Reply via email to