Skip to content

Commit 1bf936c

Browse files
committed
[fix]: 进一步完善潜在bug
1 parent 1967811 commit 1bf936c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

app/api/v1/endpoints/group.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,22 +279,27 @@ async def copy_article(folder_id: int, article_id: int, is_group: Optional[bool]
279279
raise HTTPException(status_code=404, detail="File not found")
280280

281281
old_file_path = file_path
282+
new_file_path = f"/lhcos-data/{uuid.uuid4()}.pdf"
282283

284+
with open(old_file_path, "rb") as source_file:
285+
with open(new_file_path, "wb") as dest_file:
286+
dest_file.write(source_file.read())
287+
283288
if is_group is not None and is_group is True:
284289
# 表示从群组转存到个人目录
285290
new_article_id = await crud_new_article(
286291
user_id= user.get("id"),
287292
folder_id=folder_id,
288293
article_name=title,
289-
url=old_file_path,
294+
url=new_file_path,
290295
db=db
291296
)
292297
return {"msg": "Article copied successfully", "new_article_id": new_article_id}
293298
else:
294299
new_article_id = await crud_upload_to_self_folder(
295300
name=title,
296301
folder_id=folder_id,
297-
url=old_file_path,
302+
url=new_file_path,
298303
db=db
299304
)
300305
return {"msg": "Article copied successfully", "new_article_id": new_article_id}

0 commit comments

Comments
 (0)