Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add restore_path to files in NextCloud trash #4447

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/nextcloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ Content-Type: application/vnd.api+json
"name": "Old",
"path": "/trash/Old.d93571568",
"updated_at": "Tue, 25 Jun 2024 14:31:44 GMT",
"etag": "1719326384"
"etag": "1719326384",
"restore_path": "/Old"
},
"meta": {},
"links": {
Expand Down
42 changes: 22 additions & 20 deletions model/nextcloud/nextcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@ const (
)

type File struct {
DocID string `json:"id,omitempty"`
Type string `json:"type"`
Name string `json:"name"`
Path string `json:"path"`
Size uint64 `json:"size,omitempty"`
Mime string `json:"mime,omitempty"`
Class string `json:"class,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
ETag string `json:"etag,omitempty"`
url string
DocID string `json:"id,omitempty"`
Type string `json:"type"`
Name string `json:"name"`
Path string `json:"path"`
Size uint64 `json:"size,omitempty"`
Mime string `json:"mime,omitempty"`
Class string `json:"class,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
ETag string `json:"etag,omitempty"`
RestorePath string `json:"restore_path,omitempty"`
url string
}

func (f *File) ID() string { return f.DocID }
Expand Down Expand Up @@ -205,16 +206,17 @@ func (nc *NextCloud) ListTrashed(path string) ([]jsonapi.Object, error) {
mime, class = vfs.ExtractMimeAndClassFromFilename(item.TrashedName)
}
file := &File{
DocID: item.ID,
Type: item.Type,
Name: item.TrashedName,
Path: filepath.Join(path, filepath.Base(item.Href)),
Size: item.Size,
Mime: mime,
Class: class,
UpdatedAt: item.LastModified,
ETag: item.ETag,
url: nc.buildTrashedURL(item, path),
DocID: item.ID,
Type: item.Type,
Name: item.TrashedName,
Path: filepath.Join(path, filepath.Base(item.Href)),
Size: item.Size,
Mime: mime,
Class: class,
UpdatedAt: item.LastModified,
ETag: item.ETag,
RestorePath: item.RestorePath,
url: nc.buildTrashedURL(item, path),
}
files = append(files, file)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/webdav/webdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ func (c *Client) List(path string) ([]Item, error) {
Href: href,
Name: props.Name,
TrashedName: props.TrashedName,
RestorePath: "/" + props.RestorePath,
LastModified: props.LastModified,
ETag: props.ETag,
}
Expand All @@ -266,6 +267,7 @@ type Item struct {
Href string
Name string
TrashedName string
RestorePath string
Size uint64
ContentType string
LastModified string
Expand All @@ -287,6 +289,7 @@ type props struct {
Type xml.Name `xml:"prop>resourcetype>collection"`
Name string `xml:"prop>displayname"`
TrashedName string `xml:"prop>trashbin-filename"`
RestorePath string `xml:"prop>trashbin-original-location"`
Size string `xml:"prop>getcontentlength"`
ContentType string `xml:"prop>getcontenttype"`
LastModified string `xml:"prop>getlastmodified"`
Expand All @@ -305,6 +308,7 @@ const ListFilesPayload = `<?xml version="1.0"?>
<d:getcontenttype />
<oc:fileid />
<nc:trashbin-filename />
<nc:trashbin-original-location />
</d:prop>
</d:propfind>
`
Expand Down
Loading