mirror of
https://github.com/gomods/athens
synced 2026-02-03 08:40:31 +00:00
* feat: add golangci-lint linting * chore: fix linter issues * feat: add linting into the workflow * docs: update lint docs * fix: cr suggestions * fix: remove old formatting and vetting scripts * fix: add docker make target * fix: action go caching * fix: depreciated actions checkout version * fix: cr suggestion * fix: cr suggestions --------- Co-authored-by: Manu Gupta <manugupt1@gmail.com>
37 lines
1009 B
Go
37 lines
1009 B
Go
package azureblob
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/gomods/athens/pkg/config"
|
|
"github.com/gomods/athens/pkg/errors"
|
|
"github.com/gomods/athens/pkg/observ"
|
|
)
|
|
|
|
// Exists implements the (./pkg/storage).Checker interface
|
|
// returning true if the module at version exists in storage.
|
|
func (s *Storage) Exists(ctx context.Context, module, version string) (bool, error) {
|
|
const op errors.Op = "azureblob.Exists"
|
|
ctx, span := observ.StartSpan(ctx, op.String())
|
|
defer span.End()
|
|
|
|
px := config.PackageVersionedName(module, version, "")
|
|
paths, err := s.client.ListBlobs(ctx, px)
|
|
if err != nil {
|
|
return false, errors.E(op, err, errors.M(module), errors.V(version))
|
|
}
|
|
var count int
|
|
for _, p := range paths {
|
|
// sane assumption: no duplicate keys.
|
|
switch p {
|
|
case config.PackageVersionedName(module, version, "info"):
|
|
count++
|
|
case config.PackageVersionedName(module, version, "mod"):
|
|
count++
|
|
case config.PackageVersionedName(module, version, "zip"):
|
|
count++
|
|
}
|
|
}
|
|
return count == 3, nil
|
|
}
|