Skip to content

Commit

Permalink
Fix prune.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois committed Oct 7, 2024
1 parent 7838aaa commit c7fc25a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions pex/cache/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def prune(
keys,
)
) as cursor:
for bootstrap_hash in cursor:
for [bootstrap_hash] in cursor:
bootstraps_by_hash.pop(bootstrap_hash)

user_code_by_hash = OrderedDict(
Expand All @@ -365,7 +365,7 @@ def prune(
keys,
)
) as cursor:
for code_hash in cursor:
for [code_hash] in cursor:
user_code_by_hash.pop(code_hash)

wheels_by_hash = OrderedDict(
Expand All @@ -388,7 +388,7 @@ def prune(
keys,
)
) as cursor:
for install_hash in cursor:
for [install_hash] in cursor:
wheels_by_hash.pop(install_hash)

yield itertools.chain(
Expand Down
22 changes: 11 additions & 11 deletions pex/cli/commands/cache/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from pex.cache import access as cache_access
from pex.cache import data as cache_data
from pex.cache.dirs import AtomicCacheDir, CacheDir
from pex.cache.dirs import CacheDir
from pex.cli.command import BuildTimeCommand
from pex.cli.commands.cache.bytes import ByteAmount, ByteUnits
from pex.cli.commands.cache.du import DiskUsage
Expand Down Expand Up @@ -441,11 +441,11 @@ def _purge(self):

return Ok()

def _prune_atomic_cache_dir(self, atomic_cache_dir):
# type: (AtomicCacheDir) -> DiskUsage
du = DiskUsage.collect(atomic_cache_dir.path)
def _prune_cache_dir(self, cache_dir):
# type: (str) -> DiskUsage
du = DiskUsage.collect(cache_dir)
if not self.options.dry_run:
safe_rmtree(atomic_cache_dir.path)
safe_rmtree(cache_dir)
return du

def _prune(self):
Expand Down Expand Up @@ -495,8 +495,8 @@ def _prune(self):
self._render_usage(
list(
iter_map_parallel(
pex_dirs,
self._prune_atomic_cache_dir,
(pex_dir.path for pex_dir in pex_dirs),
self._prune_cache_dir,
noun="cached PEX",
verb="prune",
verb_past="pruned",
Expand All @@ -518,8 +518,8 @@ def _prune(self):
self._render_usage(
list(
iter_map_parallel(
deps,
self._prune_atomic_cache_dir,
(dep.path for dep in deps),
self._prune_cache_dir,
noun="cached PEX dependency",
verb="prune",
verb_past="pruned",
Expand All @@ -532,8 +532,8 @@ def _prune(self):
with cache_data.prune(deps) as prunable_deps_iter:
disk_usages = list(
iter_map_parallel(
prunable_deps_iter,
self._prune_atomic_cache_dir,
(dep.path for dep in prunable_deps_iter),
self._prune_cache_dir,
noun="cached PEX dependency",
verb="prune",
verb_past="pruned",
Expand Down

0 comments on commit c7fc25a

Please sign in to comment.