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

fix wrong node to set space name #2178

Merged
merged 2 commits into from
Oct 15, 2021
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 changelog/unreleased/get-quota-storage-space.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ Implementation of [cs3org/cs3apis#147](https://github.com/cs3org/cs3apis/pull/14

Make the cs3apis accept a Reference in the getQuota Request to limit the call to a specific storage space.

https://github.com/cs3org/reva/issues/2152
https://github.com/cs3org/reva/pull/2152
https://github.com/cs3org/reva/pull/2178
2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/decomposedfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (fs *Decomposedfs) CreateHome(ctx context.Context) (err error) {
}
}

if err := n.SetMetadata(xattrs.SpaceNameAttr, u.DisplayName); err != nil {
if err := h.SetMetadata(xattrs.SpaceNameAttr, u.DisplayName); err != nil {
micbar marked this conversation as resolved.
Show resolved Hide resolved
return err
}

Expand Down
4 changes: 1 addition & 3 deletions pkg/storage/utils/decomposedfs/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,13 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide
// do not list shares as spaces for the owner
continue
}
case "project":
default:
sname, err := xattr.Get(n.InternalPath(), xattrs.SpaceNameAttr)
if err != nil {
appctx.GetLogger(ctx).Error().Err(err).Interface("node", n).Msg("could not read space name, attribute not found")
continue
}
space.Name = string(sname)
default:
space.Name = "root"
}

// filter out spaces user cannot access (currently based on stat permission)
Expand Down
13 changes: 9 additions & 4 deletions pkg/storage/utils/decomposedfs/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,15 +752,20 @@ func (upload *fileUpload) ConcatUploads(ctx context.Context, uploads []tusd.Uplo

func checkQuota(ctx context.Context, fs *Decomposedfs, spaceRoot *node.Node, fileSize uint64) (quotaSufficient bool, err error) {
used, _ := spaceRoot.GetTreeSize()
quotaB, _ := xattr.Get(spaceRoot.InternalPath(), xattrs.QuotaAttr)
total, _ := strconv.ParseUint(string(quotaB), 10, 64)

enoughDiskSpace := enoughDiskSpace(fs, spaceRoot.InternalPath(), fileSize)
if !enoughDiskSpace {
return false, errtypes.InsufficientStorage("disk full")
}
quotaB, _ := xattr.Get(spaceRoot.InternalPath(), xattrs.QuotaAttr)
var total uint64
if quotaB != nil {
total, _ = strconv.ParseUint(string(quotaB), 10, 64)
} else {
// if quota is not set, it means unlimited
return true, nil
}

if (fileSize > total-used || total < used) && !enoughDiskSpace {
if fileSize > total-used || total < used {
return false, errtypes.InsufficientStorage("quota exceeded")
}
return true, nil
Expand Down