From ac73161a45bb81ab2e1478092c53ee806a51349c Mon Sep 17 00:00:00 2001 From: Akemi Izuko Date: Sat, 23 Dec 2023 20:14:02 -0700 Subject: [PATCH] Screenshot: Retain access times in archive --- bin/screenshot_wayland.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/screenshot_wayland.py b/bin/screenshot_wayland.py index a991211..080e3d1 100755 --- a/bin/screenshot_wayland.py +++ b/bin/screenshot_wayland.py @@ -175,9 +175,15 @@ def archive_subcommand(args): sys.stdout.write(f'Progress: 0/{count}') for i, pic in enumerate(pics): - with Image.open(DIR/pic) as img: - img.save(TMP_DIR/pic.with_suffix(ext), - quality=args.quality, method=6, optimize=True) + og = DIR/pic + out = TMP_DIR/pic.with_suffix(ext) + + with Image.open(og) as img: + img.save(out, quality=args.quality, method=6, optimize=True) + + stat = os.stat(og) + os.utime(out, times=(stat.st_atime, stat.st_mtime)) + sys.stdout.write(f'\rProgress: {i+1}/{count}' + ' ' * 40) sys.stdout.write('\nDone!\n')