Skip to content

Commit

Permalink
prevent purging of enabled spaces (cs3org#2459)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Christofas authored and butonic committed Feb 14, 2022
1 parent a955d62 commit 0880fa8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/unreleased/purge-spaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ During the second step all shares, including public shares, in the space will be
When deleting a space the blobs are currently not yet deleted since the decomposedfs will receive some changes soon.

https://github.com/cs3org/reva/pull/2431
https://github.com/cs3org/reva/pull/2458
2 changes: 2 additions & 0 deletions internal/grpc/services/storageprovider/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,8 @@ func (s *service) DeleteStorageSpace(ctx context.Context, req *provider.DeleteSt
st = status.NewNotFound(ctx, "not found when deleting space")
case errtypes.PermissionDenied:
st = status.NewPermissionDenied(ctx, err, "permission denied")
case errtypes.BadRequest:
st = status.NewInvalidArg(ctx, err.Error())
default:
st = status.NewInternal(ctx, "error deleting space: "+req.Id.String())
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/storage/utils/decomposedfs/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/cs3org/reva/pkg/appctx"
ctxpkg "github.com/cs3org/reva/pkg/ctx"
"github.com/cs3org/reva/pkg/errtypes"
"github.com/cs3org/reva/pkg/rgrpc/status"
"github.com/cs3org/reva/pkg/storage/utils/decomposedfs/node"
"github.com/cs3org/reva/pkg/storage/utils/decomposedfs/xattrs"
"github.com/cs3org/reva/pkg/utils"
Expand Down Expand Up @@ -351,6 +352,9 @@ func (fs *Decomposedfs) DeleteStorageSpace(ctx context.Context, req *provider.De
}

if purge {
if !strings.Contains(req.Id.OpaqueId, node.TrashIDDelimiter) {
return errtypes.NewErrtypeFromStatus(status.NewInvalidArg(ctx, "can't purge enabled space"))
}
ip := fs.lu.InternalPath(req.Id.OpaqueId)
matches, err := filepath.Glob(ip)
if err != nil {
Expand Down

0 comments on commit 0880fa8

Please sign in to comment.