@@ -90,10 +90,10 @@ func (w *Webdav) Exists(ctx context.Context, storagePath string) bool {
9090// ListFiles implements storage.StorageListable
9191func (w * Webdav ) ListFiles (ctx context.Context , dirPath string ) ([]storagetypes.FileInfo , error ) {
9292 w .logger .Infof ("Listing files in %s" , dirPath )
93-
93+
9494 // Join with base path
9595 fullPath := path .Join (w .config .BasePath , dirPath )
96-
96+
9797 responses , err := w .client .ListDir (ctx , fullPath )
9898 if err != nil {
9999 w .logger .Errorf ("Failed to list directory %s: %v" , fullPath , err )
@@ -108,7 +108,7 @@ func (w *Webdav) ListFiles(ctx context.Context, dirPath string) ([]storagetypes.
108108 w .logger .Warnf ("Failed to unescape href %q: %v; using original value" , resp .Href , err )
109109 decodedHref = resp .Href
110110 }
111-
111+
112112 // Extract filename from href
113113 name := path .Base (strings .TrimSuffix (decodedHref , "/" ))
114114 if name == "" || name == "." {
@@ -128,15 +128,18 @@ func (w *Webdav) ListFiles(ctx context.Context, dirPath string) ([]storagetypes.
128128 }
129129
130130 isDir := resp .Propstat .Prop .ResourceType .IsCollection ()
131-
131+
132+ filePath := strings .TrimPrefix (decodedHref , path .Join ("/" , strings .Trim (path .Dir (fullPath ), "/" )))
133+ filePath = strings .TrimPrefix (filePath , "/" )
134+
132135 fileInfo := storagetypes.FileInfo {
133136 Name : name ,
134- Path : strings . TrimPrefix ( decodedHref , w . config . BasePath ),
137+ Path : path . Join ( dirPath , name ),
135138 Size : resp .Propstat .Prop .GetContentLength ,
136139 IsDir : isDir ,
137140 ModTime : modTime ,
138141 }
139-
142+
140143 files = append (files , fileInfo )
141144 }
142145
@@ -147,10 +150,10 @@ func (w *Webdav) ListFiles(ctx context.Context, dirPath string) ([]storagetypes.
147150// OpenFile implements storage.StorageReadable
148151func (w * Webdav ) OpenFile (ctx context.Context , filePath string ) (io.ReadCloser , int64 , error ) {
149152 w .logger .Infof ("Opening file %s" , filePath )
150-
153+
151154 // Join with base path
152155 fullPath := path .Join (w .config .BasePath , filePath )
153-
156+
154157 reader , size , err := w .client .ReadFile (ctx , fullPath )
155158 if err != nil {
156159 w .logger .Errorf ("Failed to open file %s: %v" , fullPath , err )
0 commit comments