From 63d0f239788a7954baa8269e0ae88b5413de89a0 Mon Sep 17 00:00:00 2001 From: Courville Software Date: Mon, 12 Feb 2024 19:27:08 +0100 Subject: [PATCH] SmbjFileEditor: check that DiskShare is still open when closing file See https://github.com/nova-video-player/aos-AVP/issues/925 See https://nova-video-player.sentry.io/issues/4269713867 --- src/com/archos/filecorelibrary/smbj/SmbjFileEditor.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/com/archos/filecorelibrary/smbj/SmbjFileEditor.java b/src/com/archos/filecorelibrary/smbj/SmbjFileEditor.java index 4954511..70fdfa2 100644 --- a/src/com/archos/filecorelibrary/smbj/SmbjFileEditor.java +++ b/src/com/archos/filecorelibrary/smbj/SmbjFileEditor.java @@ -59,7 +59,8 @@ public InputStream getInputStream() throws Exception { ObservableInputStream ois = new ObservableInputStream(is); ois.onClose(() -> {if (smbjFile != null) { log.trace("getInputStream: closing " + mUri); - smbjFile.closeSilently(); + // check that DiskShare has not already been closed (seen on sentry) + if (smbjFile.getDiskShare().isConnected()) smbjFile.closeSilently(); }}); return ois; } @@ -78,7 +79,8 @@ public InputStream getInputStream(long from) throws Exception { ObservableInputStream ois = new ObservableInputStream(is); ois.onClose(() -> {if (smbjFile != null) { log.trace("getInputStream: closing " + mUri); - smbjFile.closeSilently(); + // check that DiskShare has not already been closed (seen on sentry) + if (smbjFile.getDiskShare().isConnected()) smbjFile.closeSilently(); }}); return ois; } @@ -95,7 +97,8 @@ public OutputStream getOutputStream() throws Exception { ObservableOutputStream oos = new ObservableOutputStream(os); oos.onClose(() -> {if (smbjFile != null) { log.trace("getOutputStream: closing " + mUri); - smbjFile.closeSilently(); + // check that DiskShare has not already been closed (seen on sentry) + if (smbjFile.getDiskShare().isConnected()) smbjFile.closeSilently(); }}); return oos; }