Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions metadata/expireFilesMetadata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Here is JSon File Sample:
"repositories": {
"msys2-remote": {
"delay": 1800,
"patterns": ["**/*.db", "**/*.sig"]
"patterns": ["*.db", "**/*.db", "*.sig", "**/*.sig"]
}
}
}
Expand Down Expand Up @@ -58,7 +58,7 @@ This can fix issues with MSYS2 db metadata files. Thus you need :
"repositories": {
"msys2-remote": {
"delay": 1800,
"patterns": ["**/*.db", "**/*.sig"]
"patterns": ["*.db", "**/*.db", "*.sig", "**/*.sig"]
}
}
}
Expand Down Expand Up @@ -101,9 +101,19 @@ $ curl -u admin:password -X POST -H 'Content-Type: application/json' -d '{
> "repositories": {
> "generic-remote-msys2": {
> "delay": 1800,
> "patterns": ["**/*.db", "**/*.xz*", "**/*.sig"]
> "patterns": ["*.db", "**/*.db", "*.xz*", "**/*.xz*", "*.sig", "**/*.sig"]
> }
> }
> }' 'http://localhost:8088/artifactory/api/plugins/execute/expireFilesMetadataConfig?params=action=reset'
```

getExpireFilesMetadataConfig
-------------------------

`getExpireFilesMetadataConfig` fetches the current Expire Files Metadata JSON configuration.

Example

```
$ curl -u admin:password 'http://localhost:8088/artifactory/api/plugins/execute/getExpireFilesMetadataConfig'
```
9 changes: 8 additions & 1 deletion metadata/expireFilesMetadata/expireFilesMetadata.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.artifactory.repo.RepoPath
import org.artifactory.request.Request
import org.artifactory.resource.ResourceStreamHandle

import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
import groovy.transform.Field

Expand Down Expand Up @@ -58,15 +59,21 @@ executions {

config.repositories << json.repositories
}

getExpireFilesMetadataConfig(httpMethod: 'GET') {
message = new JsonBuilder(config).toPrettyString()
status = 200
}
}

download {
beforeDownloadRequest { Request request, RepoPath repoPath ->
config.repositories.each{ repoName, repoConfig ->
if (repoName == repoPath.repoKey) {
long delayMilliseconds = repoConfig.delay * 1000
repoConfig.patterns.each { pattern ->
PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + pattern);
if (isRemote(repoPath.repoKey) && isGeneric(repoPath.repoKey) && shouldExpire(repoPath, repoConfig.delay)) {
if (isRemote(repoPath.repoKey) && isGeneric(repoPath.repoKey) && shouldExpire(repoPath, delayMilliseconds)) {
if (matcher.matches(Paths.get(repoPath.path))){
log.debug "Expiring " + pattern
expired = true
Expand Down