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");
|
||||
Files.copy(targetPath, backupPath, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
Files.copy(audioFile, targetPath, StandardCopyOption.REPLACE_EXISTING);
|
||||
Files.move(audioFile, targetPath, StandardCopyOption.REPLACE_EXISTING);
|
||||
wasUpgraded = true;
|
||||
upgraded.incrementAndGet();
|
||||
} else {
|
||||
@@ -166,9 +166,9 @@ public class LibraryMergeService {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
// 新文件,直接复制
|
||||
// 新文件,直接移动
|
||||
Files.createDirectories(targetPath.getParent());
|
||||
Files.copy(audioFile, targetPath, StandardCopyOption.REPLACE_EXISTING);
|
||||
Files.move(audioFile, targetPath, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
|
||||
tracksMerged.incrementAndGet();
|
||||
@@ -178,7 +178,7 @@ public class LibraryMergeService {
|
||||
if (lyricsFile != null && Files.exists(lyricsFile)) {
|
||||
Path lyricsTarget = targetPath.resolveSibling(lyricsFile.getFileName().toString());
|
||||
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)) {
|
||||
Path coverTarget = albumDir.resolve("cover.jpg");
|
||||
if (!Files.exists(coverTarget)) {
|
||||
// 目标目录没有封面,直接复制
|
||||
Files.copy(coverFile, coverTarget, StandardCopyOption.REPLACE_EXISTING);
|
||||
// 目标目录没有封面,直接移动
|
||||
Files.move(coverFile, coverTarget, StandardCopyOption.REPLACE_EXISTING);
|
||||
} else {
|
||||
// 比较封面,保留更好的版本
|
||||
if (isBetterCover(coverFile, coverTarget)) {
|
||||
@@ -198,7 +198,7 @@ public class LibraryMergeService {
|
||||
Path backupPath = coverTarget.resolveSibling("cover.jpg.backup");
|
||||
Files.copy(coverTarget, backupPath, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
Files.copy(coverFile, coverTarget, StandardCopyOption.REPLACE_EXISTING);
|
||||
Files.move(coverFile, coverTarget, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user