fix local

This commit is contained in:
jxxghp
2024-07-26 22:04:50 +08:00
parent 4f4c7a5748
commit 40663b6ce7
5 changed files with 13 additions and 16 deletions
+6 -5
View File
@@ -51,10 +51,11 @@ def list(fileitem: schemas.FileItem,
:return: 所有目录和文件 :return: 所有目录和文件
""" """
file_list = StorageChain().list_files(fileitem) file_list = StorageChain().list_files(fileitem)
if sort == "name": if file_list:
file_list.sort(key=lambda x: x.name) if sort == "name":
else: file_list.sort(key=lambda x: x.name)
file_list.sort(key=lambda x: x.modify_time, reverse=True) else:
file_list.sort(key=lambda x: x.modify_time, reverse=True)
return file_list return file_list
@@ -90,7 +91,7 @@ def delete(fileitem: schemas.FileItem,
return schemas.Response(success=False) return schemas.Response(success=False)
@router.get("/download", summary="下载文件") @router.post("/download", summary="下载文件")
def download(fileitem: schemas.FileItem, def download(fileitem: schemas.FileItem,
_: schemas.TokenPayload = Depends(verify_uri_token)) -> Any: _: schemas.TokenPayload = Depends(verify_uri_token)) -> Any:
""" """
-5
View File
@@ -31,11 +31,6 @@ class SystemConfigOper(DbOper, metaclass=Singleton):
key = key.value key = key.value
# 更新内存 # 更新内存
self.__SYSTEMCONF[key] = value self.__SYSTEMCONF[key] = value
# 写入数据库
if ObjectUtils.is_obj(value):
value = json.dumps(value)
elif value is None:
value = ''
conf = SystemConfig.get_by_key(self._db, key) conf = SystemConfig.get_by_key(self._db, key)
if conf: if conf:
if value: if value:
+2 -2
View File
@@ -38,7 +38,7 @@ class FileManagerModule(_ModuleBase):
def init_module(self) -> None: def init_module(self) -> None:
# 加载模块 # 加载模块
self._storage_schemas = ModuleHelper.load('app.modules.filemanager.storage', self._storage_schemas = ModuleHelper.load('app.modules.filemanager.storage',
filter_func=lambda _, obj: hasattr(obj, 'schema')) filter_func=lambda _, obj: hasattr(obj, 'schema') and obj.schema)
@staticmethod @staticmethod
def get_name() -> str: def get_name() -> str:
@@ -264,7 +264,7 @@ class FileManagerModule(_ModuleBase):
获取存储操作对象 获取存储操作对象
""" """
for storage_schema in self._storage_schemas: for storage_schema in self._storage_schemas:
if storage_schema.schema == _storage: if storage_schema.schema and storage_schema.schema.value == _storage:
return storage_schema() return storage_schema()
return None return None
+1 -1
View File
@@ -101,7 +101,7 @@ class LocalStorage(StorageBase):
ret_items.append(self.__get_diritem(item)) ret_items.append(self.__get_diritem(item))
# 遍历所有文件,不含子目录 # 遍历所有文件,不含子目录
for item in SystemUtils.list_sub_all(path_obj): for item in SystemUtils.list_sub_file(path_obj):
ret_items.append(self.__get_fileitem(item)) ret_items.append(self.__get_fileitem(item))
return ret_items return ret_items
+4 -3
View File
@@ -241,7 +241,7 @@ class SystemUtils:
return dirs return dirs
@staticmethod @staticmethod
def list_sub_all(directory: Path) -> List[Path]: def list_sub_file(directory: Path) -> List[Path]:
""" """
列出当前目录下的所有子目录和文件(不递归) 列出当前目录下的所有子目录和文件(不递归)
""" """
@@ -249,13 +249,14 @@ class SystemUtils:
return [] return []
if directory.is_file(): if directory.is_file():
return [] return [directory]
items = [] items = []
# 遍历目录 # 遍历目录
for path in directory.iterdir(): for path in directory.iterdir():
items.append(path) if path.is_file():
items.append(path)
return items return items