From 61906fcbb460f4f92bf9a791828216004da79fe8 Mon Sep 17 00:00:00 2001 From: Pinghao Wu Date: Fri, 1 Nov 2024 21:24:17 +0800 Subject: [PATCH] CephFSDocumentsProvider: reduce stat call on dir listing --- .../java/org/safcephfs/CephFSDocumentsProvider.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/safcephfs/CephFSDocumentsProvider.java b/src/main/java/org/safcephfs/CephFSDocumentsProvider.java index 523e798..6677486 100644 --- a/src/main/java/org/safcephfs/CephFSDocumentsProvider.java +++ b/src/main/java/org/safcephfs/CephFSDocumentsProvider.java @@ -433,6 +433,15 @@ public class CephFSDocumentsProvider extends DocumentsProvider { return result; } + var cs = executor.executeWithCursorExtra(cm -> { + var st = new CephStat(); + cm.stat(path, st); + return st; + }, result); + if (cs == null) { + return result; + } + String[] thumbnails = null; try { thumbnails = executor.execute(cm -> { @@ -447,7 +456,7 @@ public class CephFSDocumentsProvider extends DocumentsProvider { } for (String entry : res) { - buildDocumentRow(path + "/", entry, result, thumbnails, null); + buildDocumentRow(path + "/", entry, result, thumbnails, cs); } return result; } -- 2.45.2