From 7056a7ad34f0959299cd73f5f945f37553de497e Mon Sep 17 00:00:00 2001 From: Alyetama <56323389+Alyetama@users.noreply.github.com> Date: Wed, 6 Dec 2023 11:59:26 -0500 Subject: [PATCH] Fix a bug with --kep-date --- README.md | 2 +- pyproject.toml | 2 +- rayim/rayim.py | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 74ca416..87a7e55 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ options: Divide the image size (WxH) by a factor of n -S, --silent Silent mode -O, --optimize Apply default optimization on the image(s) - -k, --keep-date Keep the original creation and modification date + -k, --keep-date Keep the original modification date ``` ## 📕 Examples diff --git a/pyproject.toml b/pyproject.toml index 4bd8f82..847b2ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "rayim" -version = "1.8.0" +version = "1.8.1" description = "Fast image compression for large number of images with Ray library" authors = ["Mohammad Alyetama "] license = "MIT" diff --git a/rayim/rayim.py b/rayim/rayim.py index 61a684a..d06724d 100644 --- a/rayim/rayim.py +++ b/rayim/rayim.py @@ -5,6 +5,7 @@ import copy import imghdr import io +import os import shutil import signal import sys @@ -84,7 +85,7 @@ def compress(file: str, 'Skipping...\033[49m') return - _file = file + file_stats = os.stat(file) file = Path(file) original_file_suffix = file.suffix size_1 = Path(file).stat().st_size @@ -161,7 +162,7 @@ def compress(file: str, size_2 = size_1 if keep_date: - shutil.copystat(_file, out_file) + os.utime(out_file, (file_stats.st_atime, file_stats.st_mtime)) took = round(time.time() - start, 2) if sys.stdout.isatty(): @@ -227,7 +228,7 @@ def opts() -> argparse.Namespace: '-k', '--keep-date', action='store_true', - help='Keep the original creation and modification date') + help='Keep the original modification date') parser.add_argument( 'path', nargs='+',