refactor(image): 重构图片旋转和恢复逻辑

- 将 needRotation 标志重命名为 rotationApplied
- 修改条件旋转阶段的执行逻辑,基于实际旋转角度判断
- 实现通用的图片恢复旋转功能,支持90/180/270度恢复
- 添加恢复旋转角度计算方法 getRestoreAngle
- 更新水印阶段的旋转状态检查逻辑
- 完善单元测试覆盖各种旋转场景
- 优化日志记录和错误处理流程
This commit is contained in:
2025-11-26 20:15:02 +08:00
parent 40d5874560
commit 1945639f90
23 changed files with 147 additions and 79 deletions

View File

@@ -34,13 +34,21 @@ public class TempFileManager {
}
private Path initTempDirectory() {
Path baseDir = Path.of(System.getProperty("java.io.tmpdir"), "photo_process", processId);
try {
Path systemTempDir = Files.createTempDirectory("photo_process_");
log.debug("创建临时目录: {}", systemTempDir);
return systemTempDir;
Files.createDirectories(baseDir);
log.debug("创建隔离临时目录: {}", baseDir);
return baseDir;
} catch (IOException e) {
log.warn("无法创建系统临时目录,使用当前目录", e);
return Path.of(".");
log.warn("无法创建隔离临时目录,尝试使用系统临时目录", e);
try {
Path fallback = Files.createTempDirectory("photo_process_" + processId + "_");
log.debug("创建备用临时目录: {}", fallback);
return fallback;
} catch (IOException ex) {
log.warn("无法创建系统临时目录,使用当前目录", ex);
return Path.of(".");
}
}
}