From fc69d7e6c184d796ac21e427ae1c77859d7ba800 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sat, 16 Nov 2024 10:55:17 +0800 Subject: [PATCH] fix --- app/chain/media.py | 5 +++-- app/chain/storage.py | 3 ++- app/utils/system.py | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/chain/media.py b/app/chain/media.py index 8bf758da5..33d62d34d 100644 --- a/app/chain/media.py +++ b/app/chain/media.py @@ -339,9 +339,10 @@ def __save_file(_fileitem: schemas.FileItem, _path: Path, _content: Union[bytes, return tmp_file = settings.TEMP_PATH / _path.name tmp_file.write_bytes(_content) - logger.info(f"保存文件:【{_fileitem.storage}】{_path}") _fileitem.path = str(_path.parent) - self.storagechain.upload_file(fileitem=_fileitem, path=tmp_file) + item = self.storagechain.upload_file(fileitem=_fileitem, path=tmp_file) + if item: + logger.info(f"已保存文件:{item.path}") if tmp_file.exists(): tmp_file.unlink() diff --git a/app/chain/storage.py b/app/chain/storage.py index 49b39366f..164e3ffa3 100644 --- a/app/chain/storage.py +++ b/app/chain/storage.py @@ -57,7 +57,8 @@ def download_file(self, fileitem: schemas.FileItem, path: Path = None) -> Option """ return self.run_module("download_file", fileitem=fileitem, path=path) - def upload_file(self, fileitem: schemas.FileItem, path: Path, new_name: str = None) -> Optional[bool]: + def upload_file(self, fileitem: schemas.FileItem, path: Path, + new_name: str = None) -> Optional[schemas.FileItem]: """ 上传文件 :param fileitem: 保存目录项 diff --git a/app/utils/system.py b/app/utils/system.py index 5fd203634..e8cd68f04 100644 --- a/app/utils/system.py +++ b/app/utils/system.py @@ -275,6 +275,10 @@ def list_sub_directory(directory: Path) -> List[Path]: # 遍历目录 for path in directory.iterdir(): if path.is_dir(): + if not SystemUtils.is_windows() and path.name.startswith("."): + continue + if path.name == "@eaDir": + continue dirs.append(path) return dirs