diff --git a/ocis-pkg/l10n/l10n.go b/ocis-pkg/l10n/l10n.go index 658f60fd09..89a91adf69 100644 --- a/ocis-pkg/l10n/l10n.go +++ b/ocis-pkg/l10n/l10n.go @@ -43,9 +43,10 @@ func (t Translator) Translate(str, locale string) string { // Locale returns the gotext.Locale, use `.Get` method to translate strings func (t Translator) Locale(locale string) *gotext.Locale { l := gotext.NewLocaleFS(locale, t.fs) + l.AddDomain(t.domain) // make domain configurable only if needed if locale != "en" && len(l.GetTranslations()) == 0 { l = gotext.NewLocaleFS(t.defaultLocale, t.fs) + l.AddDomain(t.domain) // make domain configurable only if needed } - l.AddDomain(t.domain) // make domain configurable only if needed return l } diff --git a/services/graph/pkg/service/v0/drives.go b/services/graph/pkg/service/v0/drives.go index c7e9f26dd8..6dbf31864b 100644 --- a/services/graph/pkg/service/v0/drives.go +++ b/services/graph/pkg/service/v0/drives.go @@ -424,8 +424,8 @@ func (g Graph) CreateDrive(w http.ResponseWriter, r *http.Request) { } space := resp.GetStorageSpace() - if driveType == _spaceTypeProject { - if err := g.applySpaceTemplate(gatewayClient, resp.GetStorageSpace().GetRoot(), r.URL.Query().Get("template")); err != nil { + if t := r.URL.Query().Get("template"); t != "" && driveType == _spaceTypeProject { + if err := g.applySpaceTemplate(r.Context(), gatewayClient, resp.GetStorageSpace().GetRoot(), t); err != nil { logger.Error().Err(err).Msg("could not apply template to space") errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, err.Error()) return diff --git a/services/graph/pkg/service/v0/graph_test.go b/services/graph/pkg/service/v0/graph_test.go index cb56ee268d..7468db8497 100644 --- a/services/graph/pkg/service/v0/graph_test.go +++ b/services/graph/pkg/service/v0/graph_test.go @@ -764,6 +764,12 @@ var _ = Describe("Graph", func() { Constraint: v0.Permission_CONSTRAINT_ALL, }, }, nil) + + gatewayClient.On("GetQuota", mock.Anything, mock.Anything).Return(&provider.GetQuotaResponse{ + Status: status.NewOK(ctx), + TotalBytes: 500, + }, nil) + jsonBody := []byte(`{"Name": "Test Space", "DriveType": "project", "Description": "This space is for testing", "DriveAlias": "project/testspace"}`) r := httptest.NewRequest(http.MethodPost, "/graph/v1.0/drives", bytes.NewBuffer(jsonBody)).WithContext(ctx) rr := httptest.NewRecorder() diff --git a/services/graph/pkg/service/v0/utils.go b/services/graph/pkg/service/v0/utils.go index 040b1cb288..ea4a64c942 100644 --- a/services/graph/pkg/service/v0/utils.go +++ b/services/graph/pkg/service/v0/utils.go @@ -446,7 +446,7 @@ func cs3ReceivedShareToLibreGraphPermissions(ctx context.Context, logger *log.Lo return permission, nil } -func (g Graph) applySpaceTemplate(gwc gateway.GatewayAPIClient, root *storageprovider.ResourceId, template string) error { +func (g Graph) applySpaceTemplate(ctx context.Context, gwc gateway.GatewayAPIClient, root *storageprovider.ResourceId, template string) error { var fsys fs.ReadDirFS switch template { @@ -465,11 +465,6 @@ func (g Graph) applySpaceTemplate(gwc gateway.GatewayAPIClient, root *storagepro mdc := metadata.NewCS3(g.config.Reva.Address, g.config.Spaces.StorageUsersAddress) mdc.SpaceRoot = root - ctx, err := utils.GetServiceUserContext(g.config.ServiceAccount.ServiceAccountID, gwc, g.config.ServiceAccount.ServiceAccountSecret) - if err != nil { - return err - } - opaque, err := uploadFolder(ctx, mdc, ".", "", nil, fsys) if err != nil { return err