Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Nov 16, 2024
1 parent 665da9d commit fc69d7e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/chain/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 2 additions & 1 deletion app/chain/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: 保存目录项
Expand Down
4 changes: 4 additions & 0 deletions app/utils/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fc69d7e

Please sign in to comment.