Skip to content

Commit

Permalink
clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
David Christofas authored and butonic committed Jul 2, 2021
1 parent 4e1430d commit a6b1a07
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions internal/grpc/services/gateway/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (s *svc) ListStorageSpaces(ctx context.Context, req *provider.ListStorageSp
}, nil
}

providers = []*registry.ProviderInfo{}
providers = make([]*registry.ProviderInfo, 0, len(res.Providers))
// FIXME filter only providers that have an id set ... currently none have?
// bug? only ProviderPath is set
for i := range res.Providers {
Expand Down Expand Up @@ -201,7 +201,7 @@ func (s *svc) ListStorageSpaces(ctx context.Context, req *provider.ListStorageSp
uniqueSpaces[spacesFromProviders[i][j].Id.OpaqueId] = spacesFromProviders[i][j]
}
}
spaces := []*provider.StorageSpace{}
spaces := make([]*provider.StorageSpace, 0, len(uniqueSpaces))
for spaceID := range uniqueSpaces {
spaces = append(spaces, uniqueSpaces[spaceID])
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/fs/owncloudsql/owncloudsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -2162,7 +2162,7 @@ func (fs *ocfs) HashFile(path string) (string, string, string, error) {

func (fs *ocfs) ListStorageSpaces(ctx context.Context, filter []*provider.ListStorageSpacesRequest_Filter) ([]*provider.StorageSpace, error) {
// TODO(corby): Implement
return nil, nil
return nil, errtypes.NotSupported("list storage spaces")
}

func readChecksumIntoResourceChecksum(ctx context.Context, checksums, algo string, ri *provider.ResourceInfo) {
Expand Down
12 changes: 5 additions & 7 deletions pkg/storage/utils/decomposedfs/decomposedfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide
return nil, err
}

var spaces []*provider.StorageSpace
spaces := make([]*provider.StorageSpace, 0, len(matches))

u, ok := user.ContextGetUser(ctx)
if !ok {
Expand Down Expand Up @@ -628,12 +628,10 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide
// -1 = uncalculated
// -2 = unknown
// -3 = unlimited
if quota, err := strconv.ParseInt(string(v), 10, 64); err == nil {
if quota >= 0 {
space.Quota = &provider.Quota{
QuotaMaxBytes: uint64(quota),
QuotaMaxFiles: math.MaxUint64, // TODO MaxUInt64? = unlimited? why even max files? 0 = unlimited?
}
if quota, err := strconv.ParseUint(string(v), 10, 64); err == nil {
space.Quota = &provider.Quota{
QuotaMaxBytes: quota,
QuotaMaxFiles: math.MaxUint64, // TODO MaxUInt64? = unlimited? why even max files? 0 = unlimited?
}
} else {
appctx.GetLogger(ctx).Debug().Err(err).Str("nodepath", matches[i]).Msg("could not read quota")
Expand Down

0 comments on commit a6b1a07

Please sign in to comment.