From 7d6f718a34bab4d445d5fb1c5dfe37cae917b6e2 Mon Sep 17 00:00:00 2001 From: Roberto Jimenez Sanchez Date: Tue, 2 Dec 2025 23:41:03 +0100 Subject: [PATCH] fix: use filepath.Dir instead of path.Dir and fix parameter shadowing - Replace path.Dir with filepath.Dir for OS-specific path handling - Rename filepath parameter to filePath to avoid shadowing filepath package - This ensures directory creation works correctly with paths containing spaces --- apps/provisioning/pkg/repository/local/local.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/provisioning/pkg/repository/local/local.go b/apps/provisioning/pkg/repository/local/local.go index 4e2482326fd..4f8bd8e26bf 100644 --- a/apps/provisioning/pkg/repository/local/local.go +++ b/apps/provisioning/pkg/repository/local/local.go @@ -288,18 +288,18 @@ func (r *localRepository) calculateFileHash(path string) (string, int64, error) return hex.EncodeToString(hasher.Sum(nil)), size, nil } -func (r *localRepository) Create(ctx context.Context, filepath string, ref string, data []byte, comment string) error { +func (r *localRepository) Create(ctx context.Context, filePath string, ref string, data []byte, comment string) error { if err := r.validateRequest(ref); err != nil { return err } - fpath := safepath.Join(r.path, filepath) + fpath := safepath.Join(r.path, filePath) _, err := os.Stat(fpath) if !errors.Is(err, os.ErrNotExist) { if err != nil { return apierrors.NewInternalError(fmt.Errorf("failed to check if file exists: %w", err)) } - return apierrors.NewAlreadyExists(schema.GroupResource{}, filepath) + return apierrors.NewAlreadyExists(schema.GroupResource{}, filePath) } if safepath.IsDir(fpath) { @@ -314,7 +314,7 @@ func (r *localRepository) Create(ctx context.Context, filepath string, ref strin return nil } - if err := os.MkdirAll(path.Dir(fpath), 0700); err != nil { + if err := os.MkdirAll(filepath.Dir(fpath), 0700); err != nil { return apierrors.NewInternalError(fmt.Errorf("failed to create path: %w", err)) } @@ -352,7 +352,7 @@ func (r *localRepository) Write(ctx context.Context, fpath, ref string, data []b return os.MkdirAll(fpath, 0700) } - if err := os.MkdirAll(path.Dir(fpath), 0700); err != nil { + if err := os.MkdirAll(filepath.Dir(fpath), 0700); err != nil { return apierrors.NewInternalError(fmt.Errorf("failed to create path: %w", err)) }