@@ -65,6 +65,7 @@ public structure LakeOptions where
6565 outFormat : OutFormat := .text
6666 offline : Bool := false
6767 outputsFile? : Option FilePath := none
68+ overwriteInputs : Bool := true
6869 forceDownload : Bool := false
6970 mappingsOnly : Bool := false
7071 service? : Option String := none
@@ -285,6 +286,7 @@ def lakeLongOption : (opt : String) → CliM PUnit
285286| "--offline" => modifyThe LakeOptions ({· with offline := true })
286287| "--wfail" => modifyThe LakeOptions ({· with failLv := .warning})
287288| "--iofail" => modifyThe LakeOptions ({· with failLv := .info})
289+ | "--keep-local" => modifyThe LakeOptions ({· with overwriteInputs := false })
288290| "--force-download" => modifyThe LakeOptions ({· with forceDownload := true })
289291| "--download-arts" => modifyThe LakeOptions ({· with mappingsOnly := false })
290292| "--mappings-only" => modifyThe LakeOptions ({· with mappingsOnly := true })
@@ -485,7 +487,7 @@ protected def get : CliM PUnit := do
485487 else
486488 return ws.defaultCacheService
487489 let map ← CacheMap.load file
488- cache.writeMap ws.root.cacheScope map service.name? (some remoteScope)
490+ cache.writeMap ws.root.cacheScope map service.name? (some remoteScope) opts.overwriteInputs
489491 let descrs ← map.collectOutputDescrs
490492 service.downloadArtifacts descrs cache remoteScope opts.forceDownload
491493 else
@@ -530,7 +532,7 @@ protected def get : CliM PUnit := do
530532 return map
531533 else
532534 findOutputs cache service pkg remoteScope opts platform toolchain
533- cache.writeMap pkg.cacheScope map service.name? (some remoteScope)
535+ cache.writeMap pkg.cacheScope map service.name? (some remoteScope) opts.overwriteInputs
534536 unless opts.mappingsOnly do
535537 let descrs ← map.collectOutputDescrs
536538 service.downloadArtifacts descrs cache remoteScope opts.forceDownload
@@ -544,7 +546,7 @@ protected def get : CliM PUnit := do
544546 let toolchain := cacheToolchain pkg toolchain
545547 try
546548 let map ← findOutputs cache service pkg remoteScope opts platform toolchain
547- cache.writeMap pkg.cacheScope map service.name? (some remoteScope)
549+ cache.writeMap pkg.cacheScope map service.name? (some remoteScope) opts.overwriteInputs
548550 unless opts.mappingsOnly do
549551 let descrs ← map.collectOutputDescrs
550552 service.downloadArtifacts descrs cache remoteScope opts.forceDownload
@@ -677,7 +679,7 @@ protected def add : CliM PUnit := do
677679 error (serviceNotFound service ws.lakeConfig.config.cache.services)
678680 return some (.ofString service)
679681 let map ← CacheMap.load file
680- ws.lakeCache.writeMap localScope map service? opts.scope?
682+ ws.lakeCache.writeMap localScope map service? opts.scope? opts.overwriteInputs
681683
682684private def stagingOutputsFile := "outputs.jsonl"
683685
@@ -754,7 +756,7 @@ protected def unstage : CliM PUnit := do
754756 unless ok do
755757 logError "failed to copy all outputs to the staging directory"
756758 exit 1
757- ws.lakeCache.writeMap localScope map service? opts.scope?
759+ ws.lakeCache.writeMap localScope map service? opts.scope? opts.overwriteInputs
758760
759761protected def putStaged : CliM PUnit := do
760762 processOptions lakeOption
0 commit comments