From 009ee2902324246f306392fd4c742c9ef533e07c Mon Sep 17 00:00:00 2001 From: Pinghao Wu Date: Sat, 26 Oct 2024 19:30:44 +0800 Subject: [PATCH] CephFSExecutor: preserve FileNotFoundException --- .../java/org/safcephfs/CephFSDocumentsProvider.java | 3 ++- src/main/java/org/safcephfs/CephFSExecutor.java | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/safcephfs/CephFSDocumentsProvider.java b/src/main/java/org/safcephfs/CephFSDocumentsProvider.java index 25eabdd..30d6971 100644 --- a/src/main/java/org/safcephfs/CephFSDocumentsProvider.java +++ b/src/main/java/org/safcephfs/CephFSDocumentsProvider.java @@ -377,7 +377,8 @@ public class CephFSDocumentsProvider extends DocumentsProvider { return result; } - private long getXattrULL(String path, String name) { + private long getXattrULL(String path, String name) + throws FileNotFoundException { var buf = new byte[32]; var l = executor.executeWithUnchecked(cm -> { return cm.getxattr(path, name, buf); diff --git a/src/main/java/org/safcephfs/CephFSExecutor.java b/src/main/java/org/safcephfs/CephFSExecutor.java index 9b55c41..5eaccc8 100644 --- a/src/main/java/org/safcephfs/CephFSExecutor.java +++ b/src/main/java/org/safcephfs/CephFSExecutor.java @@ -7,6 +7,7 @@ import android.provider.DocumentsContract; import android.system.ErrnoException; import android.system.OsConstants; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.UncheckedIOException; import java.util.Map; @@ -168,9 +169,12 @@ public class CephFSExecutor { } } - protected T executeWithCursorExtra(Operation op, Cursor c) { + protected T executeWithCursorExtra(Operation op, Cursor c) + throws FileNotFoundException { try { return execute(op); + } catch (FileNotFoundException e) { + throw e; } catch (IOException e) { var extra = new Bundle(); var msg = e.getMessage(); @@ -181,10 +185,12 @@ public class CephFSExecutor { } } - protected T executeWithUnchecked(Operation op) { + protected T executeWithUnchecked(Operation op) + throws FileNotFoundException { try { return execute(op); - // TODO preserve IOE subclasses + } catch (FileNotFoundException e) { + throw e; } catch (IOException e) { throw new UncheckedIOException(e); } -- 2.45.2