Fix Unable move temp file on Arch Linux
This commit is contained in:
@@ -202,8 +202,11 @@ public class FileDownloadTask extends Task {
|
||||
throw new IOException("Unable to delete existent file " + file);
|
||||
if (!FileUtils.makeDirectory(file.getAbsoluteFile().getParentFile()))
|
||||
throw new IOException("Unable to make parent directory " + file);
|
||||
if (!temp.renameTo(file))
|
||||
throw new IOException("Unable to move temp file from " + temp + " to " + file);
|
||||
try {
|
||||
FileUtils.cutFile(temp, file);
|
||||
} catch (Exception e) {
|
||||
throw new IOException("Unable to move temp file from " + temp + " to " + file, e);
|
||||
}
|
||||
}
|
||||
|
||||
if (downloaded != contentLength)
|
||||
|
||||
@@ -236,7 +236,12 @@ public final class FileUtils {
|
||||
doCopyFile(srcFile, destFile);
|
||||
}
|
||||
|
||||
public static void doCopyFile(File srcFile, File destFile)
|
||||
public static void cutFile(File srcFile, File destFile) throws IOException {
|
||||
copyFile(srcFile, destFile);
|
||||
srcFile.delete();
|
||||
}
|
||||
|
||||
private static void doCopyFile(File srcFile, File destFile)
|
||||
throws IOException {
|
||||
Files.copy(srcFile.toPath(), destFile.toPath(), StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user