Skip to content

Commit 1ca1184

Browse files
authored
Add restore_path to files in NextCloud trash (#4447)
2 parents 5838219 + adcc3af commit 1ca1184

File tree

3 files changed

+28
-21
lines changed

3 files changed

+28
-21
lines changed

docs/nextcloud.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,8 @@ Content-Type: application/vnd.api+json
466466
"name": "Old",
467467
"path": "/trash/Old.d93571568",
468468
"updated_at": "Tue, 25 Jun 2024 14:31:44 GMT",
469-
"etag": "1719326384"
469+
"etag": "1719326384",
470+
"restore_path": "/Old"
470471
},
471472
"meta": {},
472473
"links": {

model/nextcloud/nextcloud.go

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,17 @@ const (
3333
)
3434

3535
type File struct {
36-
DocID string `json:"id,omitempty"`
37-
Type string `json:"type"`
38-
Name string `json:"name"`
39-
Path string `json:"path"`
40-
Size uint64 `json:"size,omitempty"`
41-
Mime string `json:"mime,omitempty"`
42-
Class string `json:"class,omitempty"`
43-
UpdatedAt string `json:"updated_at,omitempty"`
44-
ETag string `json:"etag,omitempty"`
45-
url string
36+
DocID string `json:"id,omitempty"`
37+
Type string `json:"type"`
38+
Name string `json:"name"`
39+
Path string `json:"path"`
40+
Size uint64 `json:"size,omitempty"`
41+
Mime string `json:"mime,omitempty"`
42+
Class string `json:"class,omitempty"`
43+
UpdatedAt string `json:"updated_at,omitempty"`
44+
ETag string `json:"etag,omitempty"`
45+
RestorePath string `json:"restore_path,omitempty"`
46+
url string
4647
}
4748

4849
func (f *File) ID() string { return f.DocID }
@@ -205,16 +206,17 @@ func (nc *NextCloud) ListTrashed(path string) ([]jsonapi.Object, error) {
205206
mime, class = vfs.ExtractMimeAndClassFromFilename(item.TrashedName)
206207
}
207208
file := &File{
208-
DocID: item.ID,
209-
Type: item.Type,
210-
Name: item.TrashedName,
211-
Path: filepath.Join(path, filepath.Base(item.Href)),
212-
Size: item.Size,
213-
Mime: mime,
214-
Class: class,
215-
UpdatedAt: item.LastModified,
216-
ETag: item.ETag,
217-
url: nc.buildTrashedURL(item, path),
209+
DocID: item.ID,
210+
Type: item.Type,
211+
Name: item.TrashedName,
212+
Path: filepath.Join(path, filepath.Base(item.Href)),
213+
Size: item.Size,
214+
Mime: mime,
215+
Class: class,
216+
UpdatedAt: item.LastModified,
217+
ETag: item.ETag,
218+
RestorePath: item.RestorePath,
219+
url: nc.buildTrashedURL(item, path),
218220
}
219221
files = append(files, file)
220222
}

pkg/webdav/webdav.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ func (c *Client) List(path string) ([]Item, error) {
243243
Href: href,
244244
Name: props.Name,
245245
TrashedName: props.TrashedName,
246+
RestorePath: "/" + props.RestorePath,
246247
LastModified: props.LastModified,
247248
ETag: props.ETag,
248249
}
@@ -266,6 +267,7 @@ type Item struct {
266267
Href string
267268
Name string
268269
TrashedName string
270+
RestorePath string
269271
Size uint64
270272
ContentType string
271273
LastModified string
@@ -287,6 +289,7 @@ type props struct {
287289
Type xml.Name `xml:"prop>resourcetype>collection"`
288290
Name string `xml:"prop>displayname"`
289291
TrashedName string `xml:"prop>trashbin-filename"`
292+
RestorePath string `xml:"prop>trashbin-original-location"`
290293
Size string `xml:"prop>getcontentlength"`
291294
ContentType string `xml:"prop>getcontenttype"`
292295
LastModified string `xml:"prop>getlastmodified"`
@@ -305,6 +308,7 @@ const ListFilesPayload = `<?xml version="1.0"?>
305308
<d:getcontenttype />
306309
<oc:fileid />
307310
<nc:trashbin-filename />
311+
<nc:trashbin-original-location />
308312
</d:prop>
309313
</d:propfind>
310314
`

0 commit comments

Comments
 (0)