@@ -450,12 +450,19 @@ marking them as "orphaned". This method will only remove orphaned objects (pack
450450versions, artifacts, and scratch spaces) that have been continually un-used for a period
451451of `collect_delay`; which defaults to seven days.
452452
453+ Garbage collection is only applied to the "user depot", e.g. the first entry in the
454+ depot path. If you want to run `gc` on all depots set `force=true` (this might require
455+ admin privileges depending on the setup).
456+
453457Use verbose mode (`verbose=true`) for detailed output.
454458"""
455- function gc (ctx:: Context = Context (); collect_delay:: Period = Day (7 ), verbose= false , kwargs... )
459+ function gc (ctx:: Context = Context (); collect_delay:: Period = Day (7 ), verbose= false , force = false , kwargs... )
456460 Context! (ctx; kwargs... )
457461 env = ctx. env
458462
463+ # Only look at user-depot unless force=true
464+ gc_depots = force ? depots () : [depots1 ()]
465+
459466 # First, we load in our `manifest_usage.toml` files which will tell us when our
460467 # "index files" (`Manifest.toml`, `Artifacts.toml`) were last used. We will combine
461468 # this knowledge across depots, condensing it all down to a single entry per extant
@@ -472,7 +479,7 @@ function gc(ctx::Context=Context(); collect_delay::Period=Day(7), verbose=false,
472479 scratch_parents_by_depot = Dict {String, Dict{String, Set{String}}} ()
473480
474481 # Load manifest files from all depots
475- for depot in depots ()
482+ for depot in gc_depots
476483 # When a manifest/artifact.toml is installed/used, we log it within the
477484 # `manifest_usage.toml` files within `write_env_usage()` and `bind_artifact!()`
478485 function reduce_usage! (f:: Function , usage_filepath)
@@ -733,7 +740,7 @@ function gc(ctx::Context=Context(); collect_delay::Period=Day(7), verbose=false,
733740
734741 # Do an initial scan of our depots to get a preliminary `packages_to_delete`.
735742 packages_to_delete = String[]
736- for depot in depots ()
743+ for depot in gc_depots
737744 depot_orphaned_packages = String[]
738745 packagedir = abspath (depot, " packages" )
739746 if isdir (packagedir)
@@ -773,7 +780,7 @@ function gc(ctx::Context=Context(); collect_delay::Period=Day(7), verbose=false,
773780 repos_to_delete = String[]
774781 spaces_to_delete = String[]
775782
776- for depot in depots ()
783+ for depot in gc_depots
777784 # We track orphaned objects on a per-depot basis, writing out our `orphaned.toml`
778785 # tracking file immediately, only pushing onto the overall `*_to_delete` lists if
779786 # the package has been orphaned for at least a period of `collect_delay`
@@ -919,7 +926,7 @@ function gc(ctx::Context=Context(); collect_delay::Period=Day(7), verbose=false,
919926 end
920927
921928 # Prune package paths that are now empty
922- for depot in depots ()
929+ for depot in gc_depots
923930 packagedir = abspath (depot, " packages" )
924931 ! isdir (packagedir) && continue
925932
@@ -933,7 +940,7 @@ function gc(ctx::Context=Context(); collect_delay::Period=Day(7), verbose=false,
933940 end
934941
935942 # Prune scratch space UUID folders that are now empty
936- for depot in depots ()
943+ for depot in gc_depots
937944 scratch_dir = abspath (depot, " scratchspaces" )
938945 ! isdir (scratch_dir) && continue
939946
0 commit comments