From 143744c9341304e289f733f2b6c2abe7958be9d4 Mon Sep 17 00:00:00 2001 From: dramforever Date: Sat, 7 Mar 2020 02:35:19 +0800 Subject: [PATCH] nix-channels: minor fixes --- nix-channels.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nix-channels.py b/nix-channels.py index e661eb5..de19cf1 100644 --- a/nix-channels.py +++ b/nix-channels.py @@ -374,7 +374,7 @@ def garbage_collect(): for release in (working_dir / RELEASES_DIR).iterdir(): channel = release.name.split('@')[0] - date_str = (release / '.released-time').read_text + date_str = (release / '.released-time').read_text() released_date = datetime.strptime(date_str, '%Y-%m-%d %H:%M:%S') if released_date >= time_threshold: @@ -407,7 +407,7 @@ def garbage_collect(): stdout=subprocess.PIPE ) - for path in process.stdout.splitlines(): + for path in process.stdout.decode().splitlines(): closure.add(hash_part(path)) logging.info(f' - {len(closure)} paths in closure') @@ -418,16 +418,16 @@ def garbage_collect(): if not path.name.endswith('.narinfo'): continue - hash = path.split('.narinfo', 1)[0] + hash = path.name.split('.narinfo', 1)[0] if hash in closure: continue deleted += 1 if DELETE_OLD: - narinfo = parse_narinfo(path.read_text) - path.unlink() - (working_dir / STORE_DIR / narinfo['URL']).unlink() + narinfo = parse_narinfo(path.read_text()) + path.unlink(missing_ok=True) + (working_dir / STORE_DIR / narinfo['URL']).unlink(missing_ok=True) if DELETE_OLD: logging.info(f' - {deleted} paths deleted')