fix(phase-5.1): 回收/确认幂等与两前端分片重试按 CR 消项加固
- 分片回收与 savePart/complete 共用会话锁并锁内复查 mtime - 版本/教程 confirm 按 version 或 fileName+version 幂等返回既有行 - 证据登记失败补偿删除已上传对象;标签截断到列宽 32 - 用户端分片持久化 upload_id、校验包体失败、失败不再 DELETE - 后管逐片重试 2 次、放弃时删除会话;catch 台账抬到 1057/190
This commit is contained in:
+18
-6
@@ -298,13 +298,25 @@ public class ChunkedUploadService {
|
||||
long cutoff = System.currentTimeMillis() - Math.max(1, staleHours) * 3600_000L;
|
||||
try (Stream<Path> children = Files.list(root)) {
|
||||
children.forEach(child -> {
|
||||
try {
|
||||
if (Files.getLastModifiedTime(child).toMillis() < cutoff) {
|
||||
deleteQuietly(child);
|
||||
log.info("[chunk-upload] 清理过期分片会话/残留文件 path={}", child.getFileName());
|
||||
String name = child.getFileName().toString();
|
||||
Runnable sweep = () -> {
|
||||
try {
|
||||
// 复查一次 mtime:等锁期间刚被 savePart 刷新的会话不能删。
|
||||
if (Files.getLastModifiedTime(child).toMillis() < cutoff) {
|
||||
deleteQuietly(child);
|
||||
log.info("[chunk-upload] 清理过期分片会话/残留文件 path={}", child.getFileName());
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
log.warn("[chunk-upload] 条目时间戳读不出,本轮跳过该条 path={}", child.getFileName());
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
log.warn("[chunk-upload] 条目时间戳读不出,本轮跳过该条 path={}", child.getFileName());
|
||||
};
|
||||
if (UPLOAD_ID_PATTERN.matcher(name).matches()) {
|
||||
// 与 savePart/complete 共用会话锁:在飞上传不会被整点回收腰斩。
|
||||
synchronized (lockOf(name)) {
|
||||
sweep.run();
|
||||
}
|
||||
} else {
|
||||
sweep.run();
|
||||
}
|
||||
});
|
||||
} catch (IOException ex) {
|
||||
|
||||
Reference in New Issue
Block a user