Skip to content

Commit a1a003b

Browse files
authored
Merge pull request #6 from creeperCN/fix-file-already-exists-exception
fix: 修复 Files.move 时的 FileAlreadyExistsException
2 parents 72864ca + cd63f32 commit a1a003b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • src/main/java/com/github/balloonupdate/mcpatch/client

src/main/java/com/github/balloonupdate/mcpatch/client/Work.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.nio.charset.StandardCharsets;
1717
import java.nio.file.Files;
1818
import java.nio.file.Path;
19+
import java.nio.file.StandardCopyOption;
1920
import java.nio.file.attribute.FileTime;
2021
import java.util.ArrayList;
2122
import java.util.Collections;
@@ -532,7 +533,7 @@ boolean run2(Servers server) throws IOException, McpatchBusinessException {
532533
Log.debug(" To " + to);
533534

534535
if (Files.exists(from)) {
535-
Files.move(from, to);
536+
Files.move(from, to, StandardCopyOption.REPLACE_EXISTING);
536537
}
537538
}
538539

@@ -585,7 +586,7 @@ boolean run2(Servers server) throws IOException, McpatchBusinessException {
585586
throw new McpatchBusinessException("移动临时文件时,要被移动的源文件不存在: " + from);
586587
}
587588

588-
Files.move(from, to);
589+
Files.move(from, to, StandardCopyOption.REPLACE_EXISTING);
589590
}
590591

591592
// 6.清理临时文件夹

0 commit comments

Comments
 (0)