~xdavidwu/saf-cephfs

925ac3643217eca9ce93e7c92b473c7fc370410d — Pinghao Wu a month ago c02586b
CephFSDocumentsProvider: support rename
1 files changed, 17 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 +17 -0
@@ 219,6 219,20 @@ public class CephFSDocumentsProvider extends DocumentsProvider {
			AUTHORITY, toParentDocumentId(documentId)), null, 0);
	}

	public String renameDocument(String documentId, String displayName)
			throws FileNotFoundException {
		var fromPath = pathFromDocumentId(documentId);
		var parentDocumentId = toParentDocumentId(documentId);
		var toPath = pathFromDocumentId(parentDocumentId) + "/" + displayName;
		executor.executeWithUnchecked(cm -> {
			cm.rename(fromPath, toPath);
			return null;
		});
		cr.notifyChange(DocumentsContract.buildChildDocumentsUri(
			AUTHORITY, parentDocumentId), null, 0);
		return documentIdFromPath(toPath);
	}

	public boolean isChildDocument(String parentDocumentId, String documentId) {
		return documentId.startsWith(parentDocumentId) &&
			documentId.charAt(parentDocumentId.length()) == '/';


@@ 410,6 424,9 @@ public class CephFSDocumentsProvider extends DocumentsProvider {
				if (mayWrite(parentStat) && !lcs.isDir()) {
					flags |= Document.FLAG_SUPPORTS_DELETE;
				}
				if (mayWrite(parentStat)) {
					flags |= Document.FLAG_SUPPORTS_RENAME;
				}
				yield flags;
			}
			case Document.COLUMN_ICON -> {