Skip to content

Commit

Permalink
preventing error when files are not available
Browse files Browse the repository at this point in the history
This should allow deluge filebottool plugin to rename files before downloading
  • Loading branch information
bigoulours committed May 21, 2023
1 parent 8b48965 commit cf283ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion source/net/filebot/Settings.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# application settings
application.name: FileBot
application.version: 4.7.19.2
application.version: 4.7.19.3
application.revision: @{revision}

# application updates
Expand Down
18 changes: 15 additions & 3 deletions source/net/filebot/util/FileUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardCopyOption;
Expand Down Expand Up @@ -76,14 +77,20 @@ public static File moveRename(File source, File destination) throws IOException
// but ATOMIC_MOVE can only work for files on the same drive, if that is not the case there is no point trying move with ATOMIC_MOVE
if (source.equals(destination)) {
try {
return Files.move(source.toPath(), destination.toPath(), StandardCopyOption.ATOMIC_MOVE).toFile();
Files.move(source.toPath(), destination.toPath(), StandardCopyOption.ATOMIC_MOVE).toFile();
} catch (AtomicMoveNotSupportedException e) {
debug.warning(e::toString);
}
return destination;
}

// Linux and Mac OS X
return Files.move(source.toPath(), destination.toPath(), StandardCopyOption.REPLACE_EXISTING).toFile();
try {
Files.move(source.toPath(), destination.toPath(), StandardCopyOption.REPLACE_EXISTING).toFile();
} catch (NoSuchFileException e) {
debug.warning(e::toString);
}
return destination;
}

public static File copyAs(File source, File destination) throws IOException {
Expand All @@ -97,7 +104,12 @@ public static File copyAs(File source, File destination) throws IOException {
}

// copy file
return Files.copy(source.toPath(), destination.toPath(), StandardCopyOption.REPLACE_EXISTING).toFile();
try {
Files.copy(source.toPath(), destination.toPath(), StandardCopyOption.REPLACE_EXISTING).toFile();
} catch (NoSuchFileException e) {
debug.warning(e::toString);
}
return destination;
}

public static File resolve(File source, File destination) {
Expand Down

0 comments on commit cf283ae

Please sign in to comment.