forked from gomods/athens
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deleter.go
34 lines (28 loc) · 907 Bytes
/
deleter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package minio
import (
"context"
"fmt"
"github.com/gomods/athens/pkg/storage"
opentracing "github.com/opentracing/opentracing-go"
)
func (v *storageImpl) Delete(ctx context.Context, module, version string) error {
sp, ctx := opentracing.StartSpanFromContext(ctx, "storage.minio.Delete")
defer sp.Finish()
if !v.Exists(ctx, module, version) {
return storage.ErrVersionNotFound{
Module: module,
Version: version,
}
}
versionedPath := v.versionLocation(module, version)
modPath := fmt.Sprintf("%s/go.mod", versionedPath)
if err := v.minioClient.RemoveObject(v.bucketName, modPath); err != nil {
return err
}
zipPath := fmt.Sprintf("%s/source.zip", versionedPath)
if err := v.minioClient.RemoveObject(v.bucketName, zipPath); err != nil {
return err
}
infoPath := fmt.Sprintf("%s/%s.info", versionedPath, version)
return v.minioClient.RemoveObject(v.bucketName, infoPath)
}