mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-18 03:18:52 -06:00
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user