From 5be4c884fa234add28adeeb7995b1e8497c1b6fb Mon Sep 17 00:00:00 2001 From: ambition_echo Date: Tue, 22 Nov 2022 13:34:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(save=5Fimg):=20=E4=B8=8D=E5=86=8D=E6=AF=8F?= =?UTF-8?q?=E6=AC=A1=E5=88=A0=E9=99=A4cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- earth_wallpaper/systemtray.py | 6 +++--- earth_wallpaper/utils/platformInfo.py | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/earth_wallpaper/systemtray.py b/earth_wallpaper/systemtray.py index 9c6b422..7c9676d 100644 --- a/earth_wallpaper/systemtray.py +++ b/earth_wallpaper/systemtray.py @@ -86,13 +86,13 @@ def save_current_img(): picture_dir = QStandardPaths.writableLocation(QStandardPaths.PicturesLocation) + "/earth-wallpaper" if not QDir(picture_dir).exists(): QDir(picture_dir).mkpath(picture_dir) - source = QFile(os.path.join(img_dir, files[0])) + source = QFile(os.path.join(img_dir, files[-1])) - target = QFile(os.path.join(picture_dir, files[0])) + target = QFile(os.path.join(picture_dir, files[-1])) message = QMessageBox() if not target.exists(): if source.copy(target.fileName()): - logger.info(f"保存{os.path.join(img_dir, files[0])}到{os.path.join(picture_dir, files[0])}") + logger.info(f"保存{os.path.join(img_dir, files[-1])}到{os.path.join(picture_dir, files[-1])}") QMessageBox.information(message, "保存", "保存成功,已保存到用户Picture目录", QMessageBox.Yes) else: logger.warning("保存失败,原因未知") diff --git a/earth_wallpaper/utils/platformInfo.py b/earth_wallpaper/utils/platformInfo.py index c2eb0ca..6555627 100644 --- a/earth_wallpaper/utils/platformInfo.py +++ b/earth_wallpaper/utils/platformInfo.py @@ -35,8 +35,10 @@ def log_path() -> str: def check(self): if os.path.exists(self.download_dir()): - shutil.rmtree(self.download_dir()) - os.makedirs(self.download_dir()) + pass + # shutil.rmtree(self.download_dir()) + else: + os.makedirs(self.download_dir()) def get_os(self): return self.sys