Skip to content

Commit

Permalink
Replaced delete/move by copy/delete for final rezipped file
Browse files Browse the repository at this point in the history
  • Loading branch information
optyfr committed Jun 3, 2018
1 parent 38f21ba commit 4f4750a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/JTrrntzip/TorrentZipRebuild.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package JTrrntzip;

import java.io.*;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.EnumSet;
import java.util.List;
import java.util.Optional;
Expand All @@ -11,7 +18,6 @@
import java.util.zip.CheckedInputStream;
import java.util.zip.DeflaterOutputStream;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;

import JTrrntzip.SupportedFiles.ICompress;
Expand Down Expand Up @@ -105,8 +111,10 @@ public final static EnumSet<TrrntZipStatus> ReZipFiles(final List<ZippedFile> zi
zipFileOut.close();
originalZipFile.ZipFileClose();
originalZipFile.close();
filename.delete();
FileUtils.moveFile(tmpFilename, outfilename);
if(!filename.equals(outfilename))
filename.delete();
Files.copy(tmpFilename.toPath(), outfilename.toPath(), StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING);
tmpFilename.delete();
return EnumSet.of(TrrntZipStatus.ValidTrrntzip);

}
Expand Down

0 comments on commit 4f4750a

Please sign in to comment.