mirror of
https://github.com/tuna/tunasync-scripts.git
synced 2025-04-20 04:12:42 +00:00
nix-channels: Find nar files in closure separately
Resolves: https://github.com/tuna/tunasync-scripts/issues/136
This commit is contained in:
parent
350ef7a6bc
commit
8558ba5ad8
@ -409,9 +409,20 @@ def garbage_collect():
|
|||||||
for path in process.stdout.decode().splitlines():
|
for path in process.stdout.decode().splitlines():
|
||||||
closure.add(hash_part(path))
|
closure.add(hash_part(path))
|
||||||
|
|
||||||
logging.info(f' - {len(closure)} paths in closure')
|
logging.info(f' - {len(closure)} narinfo files in closure')
|
||||||
|
|
||||||
deleted = 0
|
closure_nar = set()
|
||||||
|
|
||||||
|
for hash in closure:
|
||||||
|
narinfo_path = working_dir / STORE_DIR / f'{hash}.narinfo'
|
||||||
|
narinfo = narinfo_path.read_text()
|
||||||
|
narinfo = parse_narinfo(narinfo)
|
||||||
|
closure_nar.add(narinfo['URL'])
|
||||||
|
|
||||||
|
logging.info(f' - {len(closure_nar)} nar files in closure')
|
||||||
|
|
||||||
|
deleted_narinfo = 0
|
||||||
|
deleted_nar = 0
|
||||||
|
|
||||||
for path in (working_dir / STORE_DIR).iterdir():
|
for path in (working_dir / STORE_DIR).iterdir():
|
||||||
if not path.name.endswith('.narinfo'):
|
if not path.name.endswith('.narinfo'):
|
||||||
@ -421,7 +432,7 @@ def garbage_collect():
|
|||||||
if hash in closure:
|
if hash in closure:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
deleted += 1
|
deleted_narinfo += 1
|
||||||
|
|
||||||
if DELETE_OLD:
|
if DELETE_OLD:
|
||||||
narinfo = parse_narinfo(path.read_text())
|
narinfo = parse_narinfo(path.read_text())
|
||||||
@ -434,10 +445,24 @@ def garbage_collect():
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
for path in (working_dir / STORE_DIR / 'nar').iterdir():
|
||||||
|
if f'nar/{path.name}' in closure_nar:
|
||||||
|
continue
|
||||||
|
|
||||||
|
deleted_nar += 1
|
||||||
|
|
||||||
if DELETE_OLD:
|
if DELETE_OLD:
|
||||||
logging.info(f' - {deleted} paths deleted')
|
try:
|
||||||
|
path.unlink()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if DELETE_OLD:
|
||||||
|
logging.info(f' - {deleted_narinfo} narinfo files deleted')
|
||||||
|
logging.info(f' - {deleted_nar} nar files deleted')
|
||||||
else:
|
else:
|
||||||
logging.info(f' - {deleted} paths now unreachable')
|
logging.info(f' - {deleted_narinfo} narinfo files unreachable')
|
||||||
|
logging.info(f' - {deleted_nar} nar files unreachable')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
channels = clone_channels()
|
channels = clone_channels()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user