🐛 fix(webdav): 保证流式上传取消后清理未发布文件
This commit is contained in:
1 parent
8a3147ef0d
commit
dd905c5c90
3 files changed
+9
-9
No files matched your search
@@ -1 +1 @@
|
||||
f2461378ef9a103e72d3f8ed6ea4ef6fdaecb32c
|
||||
a962f7aec7c222b1545ecb3774e95d534b1219e9
|
||||
@@ -92,11 +92,4 @@ class WebDAVStreamMixin:
|
||||
return save_path,digest
|
||||
|
||||
async def clean_stream_upload(self, upload_id, save_path):
|
||||
info = await self._stream_session(upload_id)
|
||||
if info is None:
|
||||
return
|
||||
directory = str(PurePosixPath(self._stream_part_path(info, 0)).parent)
|
||||
async with aiohttp.ClientSession(auth=self.auth, timeout=OFFSET_TIMEOUT) as client:
|
||||
async with client.delete(self._build_url(directory)) as response:
|
||||
if response.status not in (200, 204, 404):
|
||||
raise HTTPException(503, 'WebDAV 分片清理失败,请重试')
|
||||
await self.clean_offset_upload(upload_id, save_path)
|
||||
@@ -41,3 +41,10 @@ class WebDAVStreamTests(WebDAVFixture):
|
||||
await UploadChunk.filter(upload_id=uid,chunk_index=0).delete()
|
||||
self.assertEqual((await self.chunk(uid,0)).status_code,200)
|
||||
self.assertFalse(any(c[0]=='PATCH' for c in self.calls))
|
||||
|
||||
async def test_cancel_after_lost_move_reply_cleans_unpublished_destination(self):
|
||||
uid=await self.upload_all();self.fail_move_reply=True
|
||||
response=await self.complete(uid);self.assertEqual(response.status_code,503)
|
||||
self.assertIn(self.payload,self.files.values())
|
||||
cancel=await self.client.delete(f'/chunk/upload/{uid}')
|
||||
self.assertEqual(cancel.status_code,200);self.assertFalse(self.files)
|
||||
Reference in new issue
Block a user