5050
5151import static com .github .nocatch .NoCatch .noCatch ;
5252import static com .google .common .hash .Hashing .md5 ;
53- import static com .google .common .io .Files .hash ;
53+ import static com .google .common .io .Files .asByteSource ;
5454import static java .nio .file .Files .createDirectories ;
5555
5656/**
@@ -188,7 +188,7 @@ private void updateDatabase(List<StagedFile> files, short version, String modNam
188188 updateStatus ("Updating database" );
189189 List <FeaturedModFile > featuredModFiles = files .stream ()
190190 .map (file -> new FeaturedModFile ()
191- .setMd5 (noCatch (() -> hash (file .targetFile ().toFile (), md5 ())).toString ())
191+ .setMd5 (noCatch (() -> asByteSource (file .targetFile ().toFile ()). hash ( md5 ())).toString ())
192192 .setFileId (file .fileId ())
193193 .setName (file .targetFile ().getFileName ().toString ())
194194 .setVersion (version )
@@ -231,7 +231,7 @@ private List<StagedFile> packageFiles(Path repositoryDirectory, short version, M
231231 * Renames the temporary file to the target file so the file is only available under its final name when it is
232232 * complete, and makes the file readable for everyone.
233233 */
234- private StagedFile finalizeFile (StagedFile file ) {
234+ private void finalizeFile (StagedFile file ) {
235235 Path source = file .tmpFile ();
236236 Path target = file .targetFile ();
237237
@@ -240,7 +240,6 @@ private StagedFile finalizeFile(StagedFile file) {
240240
241241 log .trace ("Renaming '{}' to '{}'" , source , target );
242242 noCatch (() -> Files .move (source , target , StandardCopyOption .ATOMIC_MOVE ));
243- return file ;
244243 }
245244
246245 /**
@@ -322,24 +321,32 @@ private Path toTmpFile(Path targetFile) {
322321 */
323322 private void zipDirectory (Path directoryToZip , ZipArchiveOutputStream outputStream ) throws IOException {
324323 Files .walkFileTree (directoryToZip , new SimpleFileVisitor <>() {
324+ @ Override
325325 public FileVisitResult preVisitDirectory (Path dir , BasicFileAttributes attrs ) throws IOException {
326326 String relativized = directoryToZip .getParent ().relativize (dir ).toString ();
327327 if (!relativized .isEmpty ()) {
328328 ZipArchiveEntry zipArchiveEntry = new ZipArchiveEntry (relativized + "/" );
329+ zipArchiveEntry .setTime (FileTime .from (Instant .EPOCH ));
330+ zipArchiveEntry .setCreationTime (FileTime .from (Instant .EPOCH ));
329331 zipArchiveEntry .setLastModifiedTime (FileTime .from (Instant .EPOCH ));
332+ zipArchiveEntry .setLastAccessTime (FileTime .from (Instant .EPOCH ));
330333 outputStream .putArchiveEntry (zipArchiveEntry );
331334 outputStream .closeArchiveEntry ();
332335 }
333336
334337 return FileVisitResult .CONTINUE ;
335338 }
336339
340+ @ Override
337341 public FileVisitResult visitFile (Path file , BasicFileAttributes attrs ) throws IOException {
338342 log .trace ("Zipping file {}" , file .toAbsolutePath ());
339343 ZipArchiveEntry zipArchiveEntry = new ZipArchiveEntry (
340344 file .toFile (),
341345 directoryToZip .getParent ().relativize (file ).toString ().replace (File .separatorChar , '/' ));
346+ zipArchiveEntry .setTime (FileTime .from (Instant .EPOCH ));
347+ zipArchiveEntry .setCreationTime (FileTime .from (Instant .EPOCH ));
342348 zipArchiveEntry .setLastModifiedTime (FileTime .from (Instant .EPOCH ));
349+ zipArchiveEntry .setLastAccessTime (FileTime .from (Instant .EPOCH ));
343350
344351 outputStream .putArchiveEntry (zipArchiveEntry );
345352
0 commit comments