Refactor file handling in LibraryMergeService to use move instead of copy for audio, lyrics, and cover files. Update MergeTab.vue to include a warning about files being moved to the main library.
This commit is contained in:
@@ -141,7 +141,7 @@ public class LibraryMergeService {
|
|||||||
targetPath.getFileName().toString() + ".backup");
|
targetPath.getFileName().toString() + ".backup");
|
||||||
Files.copy(targetPath, backupPath, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(targetPath, backupPath, StandardCopyOption.REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
Files.copy(audioFile, targetPath, StandardCopyOption.REPLACE_EXISTING);
|
Files.move(audioFile, targetPath, StandardCopyOption.REPLACE_EXISTING);
|
||||||
wasUpgraded = true;
|
wasUpgraded = true;
|
||||||
upgraded.incrementAndGet();
|
upgraded.incrementAndGet();
|
||||||
} else {
|
} else {
|
||||||
@@ -166,9 +166,9 @@ public class LibraryMergeService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 新文件,直接复制
|
// 新文件,直接移动
|
||||||
Files.createDirectories(targetPath.getParent());
|
Files.createDirectories(targetPath.getParent());
|
||||||
Files.copy(audioFile, targetPath, StandardCopyOption.REPLACE_EXISTING);
|
Files.move(audioFile, targetPath, StandardCopyOption.REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
tracksMerged.incrementAndGet();
|
tracksMerged.incrementAndGet();
|
||||||
@@ -178,7 +178,7 @@ public class LibraryMergeService {
|
|||||||
if (lyricsFile != null && Files.exists(lyricsFile)) {
|
if (lyricsFile != null && Files.exists(lyricsFile)) {
|
||||||
Path lyricsTarget = targetPath.resolveSibling(lyricsFile.getFileName().toString());
|
Path lyricsTarget = targetPath.resolveSibling(lyricsFile.getFileName().toString());
|
||||||
if (!Files.exists(lyricsTarget) || wasUpgraded) {
|
if (!Files.exists(lyricsTarget) || wasUpgraded) {
|
||||||
Files.copy(lyricsFile, lyricsTarget, StandardCopyOption.REPLACE_EXISTING);
|
Files.move(lyricsFile, lyricsTarget, StandardCopyOption.REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,8 +189,8 @@ public class LibraryMergeService {
|
|||||||
if (coverFile != null && Files.exists(coverFile)) {
|
if (coverFile != null && Files.exists(coverFile)) {
|
||||||
Path coverTarget = albumDir.resolve("cover.jpg");
|
Path coverTarget = albumDir.resolve("cover.jpg");
|
||||||
if (!Files.exists(coverTarget)) {
|
if (!Files.exists(coverTarget)) {
|
||||||
// 目标目录没有封面,直接复制
|
// 目标目录没有封面,直接移动
|
||||||
Files.copy(coverFile, coverTarget, StandardCopyOption.REPLACE_EXISTING);
|
Files.move(coverFile, coverTarget, StandardCopyOption.REPLACE_EXISTING);
|
||||||
} else {
|
} else {
|
||||||
// 比较封面,保留更好的版本
|
// 比较封面,保留更好的版本
|
||||||
if (isBetterCover(coverFile, coverTarget)) {
|
if (isBetterCover(coverFile, coverTarget)) {
|
||||||
@@ -198,7 +198,7 @@ public class LibraryMergeService {
|
|||||||
Path backupPath = coverTarget.resolveSibling("cover.jpg.backup");
|
Path backupPath = coverTarget.resolveSibling("cover.jpg.backup");
|
||||||
Files.copy(coverTarget, backupPath, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(coverTarget, backupPath, StandardCopyOption.REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
Files.copy(coverFile, coverTarget, StandardCopyOption.REPLACE_EXISTING);
|
Files.move(coverFile, coverTarget, StandardCopyOption.REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,13 @@
|
|||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<div class="strategy-tip merge-tip">
|
||||||
|
<el-icon class="tip-icon"><Warning /></el-icon>
|
||||||
|
<div class="tip-content">
|
||||||
|
<strong>重要提示</strong>:文件会<strong>移动</strong>到主库(源目录 staging 中的文件会被移走,不保留);歌词和封面一并移动。
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<el-form-item label="合并策略">
|
<el-form-item label="合并策略">
|
||||||
<el-checkbox v-model="form.smartUpgrade">启用智能升级</el-checkbox>
|
<el-checkbox v-model="form.smartUpgrade">启用智能升级</el-checkbox>
|
||||||
<el-checkbox v-model="form.keepBackup">保留旧版本备份</el-checkbox>
|
<el-checkbox v-model="form.keepBackup">保留旧版本备份</el-checkbox>
|
||||||
|
|||||||
Reference in New Issue
Block a user