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 app provider new file action and improve app provider error codes #2210

Merged
merged 8 commits into from
Dec 9, 2021
8 changes: 8 additions & 0 deletions changelog/unreleased/app-provider-new-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Change: Fix app provider new file creation and improved error codes

We've fixed the behavior for the app provider when creating new files.
Previously the app provider would overwrite already existing files when creating a new file, this is now handled and prevented.
The new file endpoint accepted a path to a file, but this does not work for spaces. Therefore we now use the resource id of the folder where the file should be created and a filename to create the new file.
Also the app provider returns more useful error codes in a lot of cases.

https://github.com/cs3org/reva/pull/2210
7 changes: 5 additions & 2 deletions internal/grpc/services/gateway/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (s *svc) findAppProvider(ctx context.Context, ri *storageprovider.ResourceI

// we did not find a default provider
if res.Status.Code == rpc.Code_CODE_NOT_FOUND {
err := errtypes.NotFound(fmt.Sprintf("gateway: default app rovider for mime type:%s not found", ri.MimeType))
err := errtypes.NotFound(fmt.Sprintf("gateway: default app provider for mime type:%s not found", ri.MimeType))
return nil, err
}

Expand Down Expand Up @@ -285,7 +285,10 @@ func (s *svc) findAppProvider(ctx context.Context, ri *storageprovider.ResourceI
}
res.Providers = filteredProviders

// if we only have one app provider we verify that it matches the requested app name
if len(res.Providers) == 0 {
return nil, errtypes.NotFound(fmt.Sprintf("app '%s' not found", app))
}

if len(res.Providers) == 1 {
return res.Providers[0], nil
}
Expand Down
Loading