Fix no such file exception

This commit is contained in:
crschnick 2024-10-11 06:00:59 +00:00
parent 89885c11b8
commit a7a3b22dcd

View file

@ -158,8 +158,7 @@ public class BrowserTransferModel {
public void transferToDownloads() throws Exception {
List<Item> toMove;
synchronized (items) {
toMove =
items.stream().filter(item -> item.downloadFinished().get()).toList();
toMove = items.stream().filter(item -> item.downloadFinished().get()).toList();
if (toMove.isEmpty()) {
return;
}
@ -170,6 +169,10 @@ public class BrowserTransferModel {
var downloads = DesktopHelper.getDownloadsDirectory();
Files.createDirectories(downloads);
for (Path file : files) {
if (!Files.exists(file)) {
continue;
}
var target = downloads.resolve(file.getFileName());
// Prevent DirectoryNotEmptyException
if (Files.exists(target) && Files.isDirectory(target)) {