mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-06-28 03:02:34 +08:00
fix local
This commit is contained in:
@@ -51,10 +51,11 @@ def list(fileitem: schemas.FileItem,
|
||||
:return: 所有目录和文件
|
||||
"""
|
||||
file_list = StorageChain().list_files(fileitem)
|
||||
if sort == "name":
|
||||
file_list.sort(key=lambda x: x.name)
|
||||
else:
|
||||
file_list.sort(key=lambda x: x.modify_time, reverse=True)
|
||||
if file_list:
|
||||
if sort == "name":
|
||||
file_list.sort(key=lambda x: x.name)
|
||||
else:
|
||||
file_list.sort(key=lambda x: x.modify_time, reverse=True)
|
||||
return file_list
|
||||
|
||||
|
||||
@@ -90,7 +91,7 @@ def delete(fileitem: schemas.FileItem,
|
||||
return schemas.Response(success=False)
|
||||
|
||||
|
||||
@router.get("/download", summary="下载文件")
|
||||
@router.post("/download", summary="下载文件")
|
||||
def download(fileitem: schemas.FileItem,
|
||||
_: schemas.TokenPayload = Depends(verify_uri_token)) -> Any:
|
||||
"""
|
||||
|
||||
@@ -31,11 +31,6 @@ class SystemConfigOper(DbOper, metaclass=Singleton):
|
||||
key = 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)
|
||||
if conf:
|
||||
if value:
|
||||
|
||||
@@ -38,7 +38,7 @@ class FileManagerModule(_ModuleBase):
|
||||
def init_module(self) -> None:
|
||||
# 加载模块
|
||||
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
|
||||
def get_name() -> str:
|
||||
@@ -264,7 +264,7 @@ class FileManagerModule(_ModuleBase):
|
||||
获取存储操作对象
|
||||
"""
|
||||
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 None
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ class LocalStorage(StorageBase):
|
||||
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))
|
||||
return ret_items
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ class SystemUtils:
|
||||
return dirs
|
||||
|
||||
@staticmethod
|
||||
def list_sub_all(directory: Path) -> List[Path]:
|
||||
def list_sub_file(directory: Path) -> List[Path]:
|
||||
"""
|
||||
列出当前目录下的所有子目录和文件(不递归)
|
||||
"""
|
||||
@@ -249,13 +249,14 @@ class SystemUtils:
|
||||
return []
|
||||
|
||||
if directory.is_file():
|
||||
return []
|
||||
return [directory]
|
||||
|
||||
items = []
|
||||
|
||||
# 遍历目录
|
||||
for path in directory.iterdir():
|
||||
items.append(path)
|
||||
if path.is_file():
|
||||
items.append(path)
|
||||
|
||||
return items
|
||||
|
||||
|
||||
Reference in New Issue
Block a user