Skip to content

Commit 4cf370e

Browse files
committed
feat: add 'cache get-' flag that does not decompress (leanprover-community#3179)
Perhaps a big obscure for end-users, but useful if you would like to make sure something is in the cache, for later. Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
1 parent bff2791 commit 4cf370e

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

Cache/Main.lean

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Commands:
1313
# No priviledge required
1414
get [ARGS] Download linked files missing on the local cache and decompress
1515
get! [ARGS] Download all linked files and decompress
16+
get- [ARGS] Download linked files missing to the local cache, but do no compress
1617
pack Compress non-compressed build files into the local cache
1718
pack! Compress build files into the local cache (no skipping)
1819
unpack Decompress linked already downloaded files
@@ -50,18 +51,20 @@ def toPaths (args : List String) : List FilePath :=
5051
args.map (FilePath.mk · |>.normalize)
5152

5253
def curlArgs : List String :=
53-
["get", "get!", "put", "put!", "commit", "commit!"]
54+
["get", "get!", "get-", "put", "put!", "commit", "commit!"]
5455

5556
open Cache IO Hashing Requests in
5657
def main (args : List String) : IO Unit := do
5758
let hashMemo ← getHashMemo
5859
let hashMap := hashMemo.hashMap
5960
let goodCurl := !(curlArgs.contains (args.headD "") && !(← validateCurl))
6061
match args with
61-
| ["get"] => getFiles hashMap false goodCurl
62-
| ["get!"] => getFiles hashMap true goodCurl
63-
| "get" :: args => getFiles (← hashMemo.filterByFilePaths (toPaths args)) false goodCurl
64-
| "get!" :: args => getFiles (← hashMemo.filterByFilePaths (toPaths args)) true goodCurl
62+
| ["get"] => getFiles hashMap false goodCurl true
63+
| ["get!"] => getFiles hashMap true goodCurl true
64+
| ["get-"] => getFiles hashMap false goodCurl false
65+
| "get" :: args => getFiles (← hashMemo.filterByFilePaths (toPaths args)) false goodCurl true
66+
| "get!" :: args => getFiles (← hashMemo.filterByFilePaths (toPaths args)) true goodCurl true
67+
| "get-" :: args => getFiles (← hashMemo.filterByFilePaths (toPaths args)) false goodCurl false
6568
| ["pack"] => discard $ packCache hashMap false
6669
| ["pack!"] => discard $ packCache hashMap true
6770
| ["unpack"] => unpackCache hashMap

Cache/Requests.lean

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ def downloadFiles (hashMap : IO.HashMap) (forceDownload : Bool) (parallel : Bool
8181
else IO.println "No files to download"
8282

8383
/-- Downloads missing files, and unpacks files. -/
84-
def getFiles (hashMap : IO.HashMap) (forceDownload : Bool) (parallel : Bool) : IO Unit := do
84+
def getFiles (hashMap : IO.HashMap) (forceDownload : Bool) (parallel : Bool) (decompress : Bool) :
85+
IO Unit := do
8586
downloadFiles hashMap forceDownload parallel
86-
IO.unpackCache hashMap
87+
if decompress then
88+
IO.unpackCache hashMap
8789

8890
end Get
8991

0 commit comments

Comments
 (0)