|
1 | 1 | package org.jenkinsci.plugins.workflow.libs;
|
2 | 2 |
|
| 3 | +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
3 | 4 | import hudson.Extension;
|
4 | 5 | import hudson.FilePath;
|
5 | 6 | import hudson.model.AsyncPeriodicWork;
|
|
11 | 12 | import jenkins.util.SystemProperties;
|
12 | 13 |
|
13 | 14 | @Extension public class LibraryCachingCleanup extends AsyncPeriodicWork {
|
14 |
| - public static /* non-final for script console */ int EXPIRE_AFTER_READ_DAYS = |
| 15 | + @SuppressFBWarnings(value = "MS_SHOULD_BE_FINAL", justification = "non-final for script console access") |
| 16 | + public static int EXPIRE_AFTER_READ_DAYS = |
15 | 17 | SystemProperties.getInteger(LibraryCachingCleanup.class.getName() + ".EXPIRE_AFTER_READ_DAYS", 7);
|
16 | 18 |
|
17 | 19 | public LibraryCachingCleanup() {
|
@@ -40,10 +42,10 @@ public LibraryCachingCleanup() {
|
40 | 42 | * @return true if specified directory is a cache directory, regardless of whether it was outdated. Used to detect
|
41 | 43 | * whether the cache was created before or after the fix for SECURITY-2586.
|
42 | 44 | */
|
43 |
| - private boolean removeIfOldCacheDirectory(FilePath library, long maxDurationMillis) throws IOException, InterruptedException { |
| 45 | + private boolean removeIfOldCacheDirectory(FilePath library, long maxDurationSinceLastReadMillis) throws IOException, InterruptedException { |
44 | 46 | final FilePath lastReadFile = new FilePath(library, LibraryCachingConfiguration.LAST_READ_FILE);
|
45 | 47 | if (lastReadFile.exists()) {
|
46 |
| - if ((System.currentTimeMillis() - lastReadFile.lastModified()) > maxDurationMillis) { |
| 48 | + if ((System.currentTimeMillis() - lastReadFile.lastModified()) > maxDurationSinceLastReadMillis) { |
47 | 49 | library.deleteRecursive();
|
48 | 50 | library.withSuffix("-name.txt").delete(); // Harmless if this is a pre-SECURITY-2586 cache directory.
|
49 | 51 | }
|
|
0 commit comments