Skip to content

Commit

Permalink
Fix trash-bin purge
Browse files Browse the repository at this point in the history
  • Loading branch information
IljaN committed Jan 14, 2021
1 parent c212a4e commit dccc6cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions internal/http/services/owncloud/ocdav/trashbin.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,13 @@ func (h *TrashbinHandler) Handler(s *svc) http.Handler {
h.restore(w, r, s, u, dst, key)
return
}
if key != "" && r.Method == "DELETE" {

if r.Method == "DELETE" {
h.delete(w, r, s, u, key)
return
}

http.Error(w, "501 Forbidden", http.StatusNotImplemented)
http.Error(w, "501 Not implemented", http.StatusNotImplemented)
})
}

Expand Down
13 changes: 7 additions & 6 deletions pkg/storage/fs/ocis/recycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,15 @@ func (fs *ocisfs) PurgeRecycleItem(ctx context.Context, key string) (err error)
}

func (fs *ocisfs) EmptyRecycle(ctx context.Context) error {
u, ok := user.ContextGetUser(ctx)
// TODO what permission should we check? we could check the root node of the user? or the owner permissions on his home root node?
// The current impl will wipe your own trash. or when enable home is false the trash of the 'root'
if fs.o.EnableHome {
u := user.ContextMustGetUser(ctx)
// TODO use layout, see Tree.Delete() for problem
return os.RemoveAll(filepath.Join(fs.o.Root, "trash", u.Id.OpaqueId))
// The current impl will wipe your own trash. or when no user provided the trash of 'root'
if !ok {
return os.RemoveAll(fs.getRecycleRoot(ctx))
}
return os.RemoveAll(fs.getRecycleRoot(ctx))

// TODO use layout, see Tree.Delete() for problem
return os.RemoveAll(filepath.Join(fs.o.Root, "trash", u.Id.OpaqueId))
}

func getResourceType(isDir bool) provider.ResourceType {
Expand Down

0 comments on commit dccc6cb

Please sign in to comment.