From 656b8f298a4d35751e971cd6c5ca1f3785b5f0b7 Mon Sep 17 00:00:00 2001 From: RedDeadDepresso <94017243+RedDeadDepresso@users.noreply.github.com> Date: Sun, 6 Oct 2024 16:32:57 +0100 Subject: [PATCH] fix: rename source path --- util/file_manager.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/util/file_manager.py b/util/file_manager.py index fee9458..cfd423a 100644 --- a/util/file_manager.py +++ b/util/file_manager.py @@ -1,10 +1,10 @@ import shutil -import datetime import patoolib import subprocess import time import json +from datetime import datetime from pathlib import Path from util.logger import logger from typing import Union, Literal @@ -70,8 +70,9 @@ class FileManager: for attempt in range(max_retries): try: logger.renamed(type, base_name) - new_name = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S-%f') - destination_path = destination_path.with_stem(f"{destination_path.stem}_{new_name}") + new_stem = f"{source_path.stem}_{datetime.now().strftime('%Y-%m-%d_%H-%M-%S-%f')}" + source_path = source_path.rename(source_path.with_stem(new_stem)) + destination_path = destination_path.with_stem(new_stem) break except PermissionError: if attempt < max_retries - 1: