From 302514a469156d33eb21e52a2a82c357b9ef86f1 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sun, 30 Jun 2024 19:48:23 +0800 Subject: [PATCH] fix --- app/modules/filemanager/storage/local.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/modules/filemanager/storage/local.py b/app/modules/filemanager/storage/local.py index 5c377d60..289ea9f5 100644 --- a/app/modules/filemanager/storage/local.py +++ b/app/modules/filemanager/storage/local.py @@ -170,7 +170,22 @@ class LocalStorage(StorageBase): """ 上传文件 """ - return None + filepath = Path(fileitem.path) + if not filepath.exists(): + logger.warn(f"文件不存在:{filepath}") + return None + if not path.exists(): + filepath.rename(path) + if path.exists(): + return schemas.FileItem( + type="file", + path=str(path).replace("\\", "/"), + name=path.name, + basename=path.stem, + extension=path.suffix[1:], + size=path.stat().st_size, + modify_time=path.stat().st_mtime, + ) def copy(self, fileitem: schemas.FileItem, target_file: Path) -> bool: """