mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
overwrite mirror jars that were modified recently
This commit is contained in:
@@ -122,7 +122,11 @@ public class JarHandler extends JarHandlerBase {
|
||||
) {
|
||||
mirrorFile = new File(new File(getJarsDir()), info.mySnapshotPath);
|
||||
mirrorFileAttributes = FileSystemUtil.getAttributes(mirrorFile);
|
||||
if (mirrorFileAttributes != null && mirrorFileAttributes.length == originalAttributes.length) {
|
||||
if (mirrorFileAttributes != null &&
|
||||
mirrorFileAttributes.length == originalAttributes.length &&
|
||||
// no abs, reuse if cached file is older, mirrors can be from different projects with different modification times
|
||||
(mirrorFileAttributes.lastModified - originalAttributes.lastModified) <= FS_TIME_RESOLUTION
|
||||
) {
|
||||
return mirrorFile;
|
||||
}
|
||||
}
|
||||
@@ -166,15 +170,21 @@ public class JarHandler extends JarHandlerBase {
|
||||
mirrorFile = new File(new File(getJarsDir()), getSnapshotName(originalFile.getName(), digest));
|
||||
mirrorFileAttributes = FileSystemUtil.getAttributes(mirrorFile);
|
||||
|
||||
if (mirrorFileAttributes == null) {
|
||||
if (mirrorFileAttributes == null ||
|
||||
originalAttributes.length != mirrorFileAttributes.length ||
|
||||
mirrorFileAttributes.lastModified - originalAttributes.lastModified > FS_TIME_RESOLUTION // no abs, avoid leaving lately modified mirrors
|
||||
) {
|
||||
try {
|
||||
if (mirrorFileAttributes != null) {
|
||||
FileUtil.delete(mirrorFile);
|
||||
}
|
||||
FileUtil.rename(tempJarFile, mirrorFile);
|
||||
mirrorFile.setLastModified(originalAttributes.lastModified);
|
||||
} catch (IOException ex) {
|
||||
reportIOErrorWithJars(originalFile, mirrorFile, ex);
|
||||
return originalFile;
|
||||
}
|
||||
} else {
|
||||
assert originalAttributes.length == mirrorFileAttributes.length;
|
||||
FileUtil.delete(tempJarFile);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user