Skip to content

Commit

Permalink
Repository cache: add a put method determining the key itself
Browse files Browse the repository at this point in the history
    Add a new put method to the repository cache, that computes the cache key
    itself. The key is returned, so it can be reused without having to recompute
    it. This is a convenient interface for caching a file that was downloaded
    without prior knowledge of its hash.

    Change-Id: I6ac844f4166bf64498b87e483896d155df35475e
    PiperOrigin-RevId: 193889444
  • Loading branch information
Luca Di Grazia committed Sep 4, 2022
1 parent 824f379 commit 3e4cce5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ public synchronized Path get(String cacheKey, Path targetPath, KeyType keyType)

FileSystemUtils.createDirectoryAndParents(targetPath.getParentDirectory());
FileSystemUtils.copyFile(cacheValue, targetPath);
FileSystemUtils.touchFile(cacheValue);

return targetPath;
}
Expand Down Expand Up @@ -250,4 +249,5 @@ public Path getRootPath() {
public Path getContentAddressableCachePath() {
return contentAddressablePath;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void setUp() throws Exception {

@After
public void tearDown() throws IOException {
repositoryCachePath.deleteTree();
FileSystemUtils.deleteTree(repositoryCachePath);
}

@Test
Expand Down

0 comments on commit 3e4cce5

Please sign in to comment.