mirror of
https://github.com/theonedev/onedev.git
synced 2026-02-01 17:37:19 +00:00
Normalize cache key
This commit is contained in:
parent
cd5d276761
commit
f0004e505a
@ -39,6 +39,10 @@ public class CacheSpec implements Serializable, Validatable {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getNormalizedKey() {
|
||||
return getKey().replaceAll("[^a-zA-Z0-9\\-_\\.]", "-");
|
||||
}
|
||||
|
||||
@Editable(order=200, description="Specify path to cache. Non-absolute path is considered to be relative to job workspace. "
|
||||
+ "Please note that shell executor only allows non-absolute path here")
|
||||
@Interpolative(variableSuggester="suggestVariables")
|
||||
|
||||
@ -1312,14 +1312,14 @@ public class DefaultJobManager implements JobManager, Runnable, CodePullAuthoriz
|
||||
for (CacheSpec cacheSpec: jobContext.getCacheSpecs()) {
|
||||
Optional<CacheInstance> result = sortedInstances
|
||||
.stream()
|
||||
.filter(it->it.getCacheKey().equals(cacheSpec.getKey()))
|
||||
.filter(it->it.getCacheKey().equals(cacheSpec.getNormalizedKey()))
|
||||
.filter(it->!allAllocated.contains(it.getName()))
|
||||
.findFirst();
|
||||
CacheInstance allocation;
|
||||
if (result.isPresent())
|
||||
allocation = result.get();
|
||||
else
|
||||
allocation = new CacheInstance(UUID.randomUUID().toString(), cacheSpec.getKey());
|
||||
allocation = new CacheInstance(UUID.randomUUID().toString(), cacheSpec.getNormalizedKey());
|
||||
allocations.put(allocation, cacheSpec.getPath());
|
||||
jobContext.getAllocatedCaches().add(allocation.getName());
|
||||
allAllocated.add(allocation.getName());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user