diff --git a/.golangci.yml b/.golangci.yml index e2c73f0c..3db0f15e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -18,6 +18,6 @@ linters-settings: lll: line-length: 120 funlen: - lines: 85 - statements: 45 + lines: 70 + statements: 40 diff --git a/archive/tar/tar.go b/archive/tar/tar.go index 8e8ed2ab..078a9193 100644 --- a/archive/tar/tar.go +++ b/archive/tar/tar.go @@ -125,7 +125,9 @@ func relative(parent string, path string) (string, error) { for strings.HasPrefix(rel, "../") { rel = strings.TrimPrefix(rel, "../") } + rel = filepath.ToSlash(rel) + return strings.TrimPrefix(filepath.Join(rel, name), "/"), nil } diff --git a/cache/cache.go b/cache/cache.go index b12a57e7..48d91c37 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -50,8 +50,10 @@ func New(logger log.Logger, s storage.Storage, a archive.Archive, g key.Generato } return &cache{ - NewRebuilder(log.With(logger, "component", "rebuilder"), s, a, g, options.fallbackGenerator, options.namespace, options.override), - NewRestorer(log.With(logger, "component", "restorer"), s, a, g, options.fallbackGenerator, options.namespace), + NewRebuilder(log.With(logger, "component", "rebuilder"), s, a, g, + options.fallbackGenerator, options.namespace, options.override), + NewRestorer(log.With(logger, "component", "restorer"), s, a, g, + options.fallbackGenerator, options.namespace), NewFlusher(log.With(logger, "component", "flusher"), s, time.Hour), } } diff --git a/internal/plugin/config.go b/internal/plugin/config.go index 5e253036..ce2536de 100644 --- a/internal/plugin/config.go +++ b/internal/plugin/config.go @@ -25,9 +25,9 @@ type Config struct { // Optional SkipSymlinks bool + Override bool CompressionLevel int StorageOperationTimeout time.Duration - Override bool Mount []string diff --git a/internal/plugin/plugin.go b/internal/plugin/plugin.go index bc22b533..10f2c35a 100644 --- a/internal/plugin/plugin.go +++ b/internal/plugin/plugin.go @@ -42,7 +42,7 @@ func New(logger log.Logger) *Plugin { } // Exec entry point of Plugin, where the magic happens. -func (p *Plugin) Exec() error { +func (p *Plugin) Exec() error { //nolint:funlen cfg := p.Config // 1. Check parameters diff --git a/storage/backend/azure/azure.go b/storage/backend/azure/azure.go index 883ef30b..d4ededb4 100644 --- a/storage/backend/azure/azure.go +++ b/storage/backend/azure/azure.go @@ -130,9 +130,11 @@ func (b *Backend) Exists(ctx context.Context, p string) (bool, error) { b.logger.Log("msg", "checking if the object already exists", "name", p) blobURL := b.containerURL.NewBlockBlobURL(p) + get, err := blobURL.GetProperties(ctx, azblob.BlobAccessConditions{}) if err != nil { return false, fmt.Errorf("check if object exists, %w", err) } + return get.StatusCode() == http.StatusOK, nil } diff --git a/storage/backend/filesystem/filesystem.go b/storage/backend/filesystem/filesystem.go index 5fc4fb09..8c745410 100644 --- a/storage/backend/filesystem/filesystem.go +++ b/storage/backend/filesystem/filesystem.go @@ -127,5 +127,6 @@ func (b *Backend) Exists(ctx context.Context, p string) (bool, error) { if err != nil && !os.IsNotExist(err) { return false, fmt.Errorf("check the object exists, %w", err) } + return err == nil, nil } diff --git a/storage/backend/s3/s3.go b/storage/backend/s3/s3.go index 6d976607..510f7b5c 100644 --- a/storage/backend/s3/s3.go +++ b/storage/backend/s3/s3.go @@ -132,7 +132,7 @@ func (b *Backend) Exists(ctx context.Context, p string) (bool, error) { return false, fmt.Errorf("head the object, %w", err) } - // Normaly if file not exists it will be already detected by error above but in some cases + // Normally if file not exists it will be already detected by error above but in some cases // Minio can return success status for without ETag, detect that here. return *out.ETag != "", nil }