From bc5c44b4d7a9e8242d7a45105e57fba618fd0de0 Mon Sep 17 00:00:00 2001 From: sdw086 Date: Mon, 9 Mar 2026 10:57:59 +0900 Subject: [PATCH] =?UTF-8?q?[=ED=8C=8C=EC=9D=BC=20=EC=97=85=EB=A1=9C?= =?UTF-8?q?=EB=93=9C]=20tusHook=20=EC=9E=91=EC=97=85=20-=20=EC=A2=85?= =?UTF-8?q?=EB=A3=8C=EC=9D=B8=20=EC=83=81=ED=83=9C=20update=20=EB=90=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/file/service/FileService.java | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/alist/api/common/modules/file/service/FileService.java b/src/main/java/com/alist/api/common/modules/file/service/FileService.java index a8cde3e..465dd22 100644 --- a/src/main/java/com/alist/api/common/modules/file/service/FileService.java +++ b/src/main/java/com/alist/api/common/modules/file/service/FileService.java @@ -222,21 +222,54 @@ public class FileService { tusHookDto.setUploadedBytes(offset); + Integer currentStatus = fileUploadMetaInfo.getStatus(); + if (currentStatus != null && (currentStatus == 3 || currentStatus == 5)) { + String t = (type == null) ? "" : type; + if (!"post-finish".equals(t) && !"post-terminate".equals(t)) { + return false; + } + } + switch (type) { - case "pre-create", "post-receive": + case "pre-create": + // 이미 진행 이상이면 되돌리지 않음 + if (currentStatus != null && currentStatus >= 1) { + return false; + } + tusHookDto.setStatus(1); // UPLOADING break; + + case "post-receive": + // DONE/CANCELED 이후 늦게 온 receive 이벤트 무시 + if (currentStatus != null && (currentStatus == 3 || currentStatus == 5)) { + return false; + } + + tusHookDto.setStatus(1); // UPLOADING + break; + case "post-finish": tusHookDto.setStatus(3); // DONE tusHookDto.setUploadedBytes(size); break; + case "post-terminate": - tusHookDto.setStatus(5); // CANCELED (정책에 따라 FAILED=4) + // 이미 DONE이면 terminate 무시 (완료 우선) + if (currentStatus != null && currentStatus == 3) { + return false; + } + tusHookDto.setStatus(5); // CANCELED break; + default: return false; } + if (tusHookDto.getStatus() == 1 && currentStatus != null && currentStatus >= 3) { + return false; + } + fileMapper.updateFileDetailStatus(tusHookDto); if ("post-finish".equals(type) || "post-terminate".equals(type)) {