Created
March 17, 2016 13:11
-
-
Save jblaine/bbada6fbe5286063d5df to your computer and use it in GitHub Desktop.
Caused by: java.lang.ClassFormatError: Illegal class name "expire-R-PACKAGES-gz$getCacheAge" in class file expire-R-PACKAGES-gz$getCacheAge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.artifactory.fs.FileInfo | |
import org.artifactory.repo.RepoPath | |
import org.artifactory.request.Request | |
import static CacheConstants.PACKAGES_GZ_CACHE_MILLIS | |
class CacheConstants { | |
static final long PACKAGES_GZ_CACHE_MILLIS = 1800 * 1000L | |
} | |
download { | |
beforeDownloadRequest { Request request, RepoPath repoPath -> | |
if (repoPath.path.endsWith("/PACKAGES.gz") && isRemote(repoPath.repoKey) && shouldExpire(repoPath)) { | |
log.warn 'DEBUG: Expiring PACKAGES.gz' | |
expired = true | |
} else { | |
log.warn 'DEBUG: Not expiring PACKAGES.gz' | |
} | |
} | |
} | |
def isRemote(String repoKey) { | |
return repositories.getRemoteRepositories().contains(repoKey) | |
} | |
def shouldExpire(RepoPath repoPath) { | |
if (!repositories.exists(repoPath)) { | |
return false | |
} | |
FileInfo fileInfo = repositories.getFileInfo(repoPath) | |
long cacheAge = getCacheAge(fileInfo) | |
return cacheAge > PACKAGES_GZ_CACHE_MILLIS || cacheAge == -1 | |
} | |
def getCacheAge(FileInfo fileInfo) { | |
long lastUpdated = fileInfo.lastUpdated | |
if (lastUpdated <= 0) { | |
return -1 | |
} | |
return System.currentTimeMillis() - lastUpdated | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment