~xdavidwu/saf-cephfs

944b4b105ce834b61f3eabe1f221be7aec458ca0 — Pinghao Wu a month ago ecf6fd5
CephFSDocumentsProvider: cheaper getDocumentType
1 files changed, 15 insertions(+), 0 deletions(-)

M src/main/java/org/safcephfs/CephFSDocumentsProvider.java
M src/main/java/org/safcephfs/CephFSDocumentsProvider.java => src/main/java/org/safcephfs/CephFSDocumentsProvider.java +15 -0
@@ 443,6 443,21 @@ public class CephFSDocumentsProvider extends DocumentsProvider {
		return result;
	}

	// default implementation query without projection, which is costly
	// TODO try to upstream the idea?
	public String getDocumentType(String documentId)
			throws FileNotFoundException {
		try (var c = new UncheckedAutoCloseable<Cursor>(queryDocument(
				documentId, new String[]{Document.COLUMN_MIME_TYPE}))) {
			if (c.c().moveToFirst()) {
				return c.c().getString(
					c.c().getColumnIndexOrThrow(Document.COLUMN_MIME_TYPE));
			} else {
				return null;
			}
		}
	}

	private long getXattrULL(String path, String name)
			throws FileNotFoundException {
		var buf = new byte[32];