Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-cherednik committed Feb 22, 2025
1 parent 6e715ca commit 05414d8
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/main/java/ru/olegcherednik/zip4jvm/engine/zip/ZipEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;

import static ru.olegcherednik.zip4jvm.utils.ValidationUtils.requireNotBlank;
Expand Down Expand Up @@ -224,8 +225,8 @@ private void removeOriginalZipFiles() throws IOException {
private void moveTempZipFiles() throws IOException {
for (int diskNo = 0; diskNo <= tempZipModel.getTotalDisks(); diskNo++) {
Path src = tempZipModel.getDisk(diskNo);
Path dest = zip.getParent().resolve(src.getFileName());
Files.move(src, dest);
Path dst = zip.getParent().resolve(src.getFileName());
Files.move(src, dst);
}

Files.deleteIfExists(tempZipModel.getSrcZip().getPath().getParent());
Expand Down Expand Up @@ -256,11 +257,9 @@ private static ZipModel createTempZipModel(Path zip, ZipSettings settings, Map<S
}

private static Path createTempZip(Path zip) {
return Quietly.doRuntime(() -> {
Path dir = zip.getParent().resolve("tmp");
Files.createDirectories(dir);
return dir.resolve(zip.getFileName());
});
Path dir = zip.getParent().resolve("tmp_" + UUID.randomUUID());
Quietly.doRuntime(() -> Files.createDirectories(dir));
return dir.resolve(zip.getFileName());
}

private static DataOutput creatDataOutput(ZipModel zipModel) throws IOException {
Expand Down

0 comments on commit 05414d8

Please sign in to comment.