From ed302d71563d3d27add0ed49188a22a59539593f Mon Sep 17 00:00:00 2001 From: Jaime Idolpx Date: Sun, 7 Jun 2026 17:59:06 -0400 Subject: [PATCH] feat: enhance display name handling for WebDAV entries and directory collections --- src/app/webdav.ts | 6 +++++- webdav3.py | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/webdav.ts b/src/app/webdav.ts index 6682316..e91c76d 100644 --- a/src/app/webdav.ts +++ b/src/app/webdav.ts @@ -126,8 +126,12 @@ function pathFromUri(uri: string, baseUrl: string): string { function toEntryInfo(e: WebDAVEntry, baseUrl: string): EntryInfo { const rawPath = e.path && e.path.length > 0 ? e.path : e.uri; const fullPath = pathFromUri(rawPath, baseUrl); + // Some servers (notably webdav3.py) report the full path as the + // for collections. Always use the leaf of the resolved + // path so the UI shows a name, not a path. + const name = basename(fullPath) || e.name; return { - name: e.name, + name, path: fullPath, type: e.isDir ? 'folder' : 'file', size: typeof e.size === 'number' ? e.size : 0, diff --git a/webdav3.py b/webdav3.py index b2fa563..c65bc92 100644 --- a/webdav3.py +++ b/webdav3.py @@ -161,6 +161,13 @@ class DirCollection(FileMember, Collection): p = FileMember.getProperties(self) # inherit file properties p['iscollection'] = 1 p['getcontenttype'] = DirCollection.COLLECTION_MIME_TYPE + # Inherited displayname is `self.name`, which for a DirCollection is the + # full virtual path (e.g. "/sd/40 tracks/") because __init__ sets + # self.name = virdir. WebDAV clients expect a basename, so override it + # with just the leaf name. + leaf = os.path.basename(self.fsname.rstrip('/\\')) + if leaf: + p['displayname'] = leaf return p def getMembers(self):