Skip to content

Commit

Permalink
Make sure the last modified timestamp is set correctly
Browse files Browse the repository at this point in the history
Linux stores modification time with nano-seconds precision, but we
currently set the timestamp of the cached file only in milliseconds.
This can lead to the situation that the source is considered a few
nanoseconds older than the cache file and therefore the cache is
regenerated every time.
  • Loading branch information
laeubi committed Aug 19, 2023
1 parent 2fcedec commit 9a28315
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private static WrappedBundle getWrappedNode(DependencyNode node,
messages.add(new ProcessingMessage(artifact, Type.WARN, warn));
}
}
wrapArtifactFile.setLastModified(originalFile.lastModified());
Files.setLastModifiedTime(wrapArtifactFile.toPath(), Files.getLastModifiedTime(originalFile.toPath()));
visited.put(node, wrappedNode = new WrappedBundle(node, depends, key, wrapArtifactFile.toPath(),
new Jar(wrapArtifactFile), messages));
} else {
Expand Down Expand Up @@ -301,7 +301,7 @@ public static boolean isOutdated(Path cacheFile, Path sourceFile) throws IOExcep
if (Files.exists(cacheFile)) {
FileTime sourceTimeStamp = Files.getLastModifiedTime(sourceFile);
FileTime cacheTimeStamp = Files.getLastModifiedTime(cacheFile);
return sourceTimeStamp.compareTo(cacheTimeStamp) > 0;
return sourceTimeStamp.toMillis() > cacheTimeStamp.toMillis();
}
return true;
}
Expand Down

0 comments on commit 9a28315

Please sign in to comment.