Skip to content

Commit

Permalink
fix: Sanitize the name of the created directory
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Mar 9, 2023
1 parent f84c866 commit 739e774
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/crud/crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,26 @@ func (a App) sanitizeOrphan(ctx context.Context, directories Items, item absto.I
return absto.Item{}
}

logger.Info("Creating folder `%s`", dirname)
sanitizedName, err := provider.SanitizeName(dirname, false)
if err != nil {
logger.Error("sanitize name for directory `%s`: %s", dirname, err)
return absto.Item{}
}

logger.Info("Creating folder `%s`", sanitizedName)

if err := a.storageApp.CreateDir(ctx, dirname); err != nil {
if err := a.storageApp.CreateDir(ctx, sanitizedName); err != nil {
logger.Error("create a parent directory for `%s`: %s", item.Pathname, err)
return absto.Item{}
}

item, err := a.storageApp.Info(ctx, dirname)
directoryItem, err := a.storageApp.Info(ctx, sanitizedName)
if err != nil {
logger.Error("getting the parent directory infos `%s`: %s", item.Pathname, err)
return absto.Item{}
}

return item
return directoryItem
}

func (a App) rename(ctx context.Context, item absto.Item, name string) absto.Item {
Expand Down

0 comments on commit 739e774

Please sign in to comment.