From 63a6bc82c80a3752f4ecda8482d8f748e68cd136 Mon Sep 17 00:00:00 2001 From: sdw086 Date: Mon, 9 Mar 2026 17:50:33 +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=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=9D=B4=EB=8F=99=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/modules/file/service/FileService.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 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 7c693ac..9d5def1 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 @@ -320,6 +320,7 @@ public class FileService { // 1회 빠른 이동 시도 (성공하면 MOVE_YN=Y) tryMoveNowByFileUuid(tusHookDto.getFileUuid()); } catch (Exception moveEx) { + log.error("Immediate move failed. fileUuid={}", tusHookDto.getFileUuid(), moveEx); // 실패하면 큐 처리 대상으로 남기기 (MOVE_YN=N, 에러 기록) markMovePending(tusHookDto.getFileUuid(), truncateErr(moveEx.getMessage())); } @@ -332,26 +333,25 @@ public class FileService { public void tryMoveNowByFileUuid(String fileUuid) throws IOException { FileMoveTaskDto task = fileMapper.selectMoveTaskByFileUuid(fileUuid); if (task == null) return; - if (!"N".equalsIgnoreCase(task.getMoveYn())) return; - - // 임시 경로 계산 (운영 경로 규칙에 맞게 구현) - Path tmpPath = resolveTmpPath(task); // ex) /uploads/tmp/{tusUploadId} - Path finalPath = buildFinalPath(task); // ex) /uploads/{yyyy}/{MM}/{uuid}.{ext} + if (task.getMoveYn() != null && !"N".equalsIgnoreCase(task.getMoveYn())) return; + Path tmpPath = resolveTmpPath(task); + Path finalPath = buildFinalPath(task); Files.createDirectories(finalPath.getParent()); try { Files.move(tmpPath, finalPath, StandardCopyOption.ATOMIC_MOVE); } catch (AtomicMoveNotSupportedException ex) { - // cross-device 대비 fallback Files.copy(tmpPath, finalPath, StandardCopyOption.REPLACE_EXISTING); Files.deleteIfExists(tmpPath); + } catch (Exception ex) { + log.error("Move failed. fileUuid={}, tmpPath={}, finalPath={}", fileUuid, tmpPath, finalPath, ex); + throw ex; } - task.setSavePath(toSavePath(finalPath)); // DB 저장용 상대경로 + task.setSavePath(toSavePath(finalPath)); task.setSaveName(finalPath.getFileName().toString()); task.setExt(extractExt(task.getSaveName())); - fileMapper.updateFileMoveSuccess(task); }