From a77f1b5fb602b4e5b61441523018f1f8aa26709f Mon Sep 17 00:00:00 2001 From: crschnick Date: Wed, 9 Oct 2024 10:26:11 +0000 Subject: [PATCH] Check if file has been deleted during transfer --- .../browser/file/BrowserFileTransferOperation.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/java/io/xpipe/app/browser/file/BrowserFileTransferOperation.java b/app/src/main/java/io/xpipe/app/browser/file/BrowserFileTransferOperation.java index 6e49f8a4a..8834881f6 100644 --- a/app/src/main/java/io/xpipe/app/browser/file/BrowserFileTransferOperation.java +++ b/app/src/main/java/io/xpipe/app/browser/file/BrowserFileTransferOperation.java @@ -179,6 +179,12 @@ public class BrowserFileTransferOperation { AtomicLong totalSize = new AtomicLong(); if (source.getKind() == FileKind.DIRECTORY) { + // Source might have been deleted meanwhile + var exists = source.getFileSystem().directoryExists(source.getPath()); + if (!exists) { + return; + } + var directoryName = FileNames.getFileName(source.getPath()); flatFiles.put(source, directoryName); @@ -193,6 +199,12 @@ public class BrowserFileTransferOperation { } } } else { + // Source might have been deleted meanwhile + var exists = source.getFileSystem().fileExists(source.getPath()); + if (!exists) { + return; + } + flatFiles.put(source, FileNames.getFileName(source.getPath())); // Recalculate as it could have been changed meanwhile totalSize.addAndGet(source.getFileSystem().getFileSize(source.getPath()));