2015-05-10 15:20:58 +00:00
|
|
|
package s3
|
|
|
|
|
|
|
|
import (
|
2017-05-13 19:18:14 +00:00
|
|
|
"fmt"
|
2015-05-10 15:20:58 +00:00
|
|
|
"io"
|
2017-05-13 21:55:22 +00:00
|
|
|
"os"
|
2016-02-15 17:47:10 +00:00
|
|
|
"path"
|
2016-08-31 20:39:36 +00:00
|
|
|
"restic"
|
2015-05-10 15:20:58 +00:00
|
|
|
"strings"
|
2017-03-14 22:05:51 +00:00
|
|
|
"sync"
|
2017-05-15 21:37:02 +00:00
|
|
|
"time"
|
2015-05-10 15:20:58 +00:00
|
|
|
|
2017-01-22 21:01:12 +00:00
|
|
|
"restic/backend"
|
2016-09-01 20:17:37 +00:00
|
|
|
"restic/errors"
|
2016-08-21 15:46:23 +00:00
|
|
|
|
2015-11-06 21:31:59 +00:00
|
|
|
"github.com/minio/minio-go"
|
2015-05-10 15:20:58 +00:00
|
|
|
|
2016-02-14 14:29:28 +00:00
|
|
|
"restic/debug"
|
2015-05-10 15:20:58 +00:00
|
|
|
)
|
|
|
|
|
2017-04-17 17:18:58 +00:00
|
|
|
const connLimit = 10
|
2015-05-10 15:20:58 +00:00
|
|
|
|
2016-01-26 21:19:10 +00:00
|
|
|
// s3 is a backend which stores the data on an S3 endpoint.
|
|
|
|
type s3 struct {
|
2017-03-14 12:51:34 +00:00
|
|
|
client *minio.Client
|
|
|
|
connChan chan struct{}
|
|
|
|
bucketname string
|
|
|
|
prefix string
|
2017-03-14 22:05:51 +00:00
|
|
|
cacheMutex sync.RWMutex
|
|
|
|
cacheObjSize map[string]int64
|
2017-04-11 20:04:18 +00:00
|
|
|
backend.Layout
|
2015-05-15 22:29:48 +00:00
|
|
|
}
|
|
|
|
|
2017-05-15 21:37:02 +00:00
|
|
|
const defaultLayout = "s3legacy"
|
|
|
|
|
2015-12-28 17:55:15 +00:00
|
|
|
// Open opens the S3 backend at bucket and region. The bucket is created if it
|
|
|
|
// does not exist yet.
|
2016-08-31 20:39:36 +00:00
|
|
|
func Open(cfg Config) (restic.Backend, error) {
|
2016-09-27 20:35:08 +00:00
|
|
|
debug.Log("open, config %#v", cfg)
|
2015-05-10 15:20:58 +00:00
|
|
|
|
2016-06-08 19:33:18 +00:00
|
|
|
client, err := minio.New(cfg.Endpoint, cfg.KeyID, cfg.Secret, !cfg.UseHTTP)
|
2015-12-06 22:21:48 +00:00
|
|
|
if err != nil {
|
2016-08-29 19:54:50 +00:00
|
|
|
return nil, errors.Wrap(err, "minio.New")
|
2015-08-26 11:25:05 +00:00
|
|
|
}
|
|
|
|
|
2017-03-14 22:05:51 +00:00
|
|
|
be := &s3{
|
|
|
|
client: client,
|
|
|
|
bucketname: cfg.Bucket,
|
|
|
|
prefix: cfg.Prefix,
|
|
|
|
cacheObjSize: make(map[string]int64),
|
|
|
|
}
|
2017-02-10 18:24:54 +00:00
|
|
|
|
2017-05-01 17:30:52 +00:00
|
|
|
client.SetCustomTransport(backend.Transport())
|
2017-02-10 18:24:54 +00:00
|
|
|
|
2017-05-15 21:37:02 +00:00
|
|
|
l, err := backend.ParseLayout(be, cfg.Layout, defaultLayout, cfg.Prefix)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
be.Layout = l
|
|
|
|
|
2015-12-06 22:21:48 +00:00
|
|
|
be.createConnections()
|
|
|
|
|
2016-12-05 22:12:30 +00:00
|
|
|
found, err := client.BucketExists(cfg.Bucket)
|
2016-08-21 14:14:58 +00:00
|
|
|
if err != nil {
|
2016-12-05 22:12:30 +00:00
|
|
|
debug.Log("BucketExists(%v) returned err %v", cfg.Bucket, err)
|
2016-08-29 19:54:50 +00:00
|
|
|
return nil, errors.Wrap(err, "client.BucketExists")
|
2016-08-21 14:14:58 +00:00
|
|
|
}
|
2015-12-28 17:55:15 +00:00
|
|
|
|
2016-12-05 22:12:30 +00:00
|
|
|
if !found {
|
2016-01-03 20:46:07 +00:00
|
|
|
// create new bucket with default ACL in default region
|
2016-04-18 19:29:17 +00:00
|
|
|
err = client.MakeBucket(cfg.Bucket, "")
|
2016-01-03 20:46:07 +00:00
|
|
|
if err != nil {
|
2016-08-29 19:54:50 +00:00
|
|
|
return nil, errors.Wrap(err, "client.MakeBucket")
|
2016-01-03 20:46:07 +00:00
|
|
|
}
|
2015-11-06 21:31:59 +00:00
|
|
|
}
|
|
|
|
|
2015-12-06 22:21:48 +00:00
|
|
|
return be, nil
|
|
|
|
}
|
|
|
|
|
2016-01-26 21:19:10 +00:00
|
|
|
func (be *s3) createConnections() {
|
2015-12-06 22:21:48 +00:00
|
|
|
be.connChan = make(chan struct{}, connLimit)
|
|
|
|
for i := 0; i < connLimit; i++ {
|
|
|
|
be.connChan <- struct{}{}
|
|
|
|
}
|
2015-05-10 15:20:58 +00:00
|
|
|
}
|
|
|
|
|
2017-05-15 21:37:02 +00:00
|
|
|
// IsNotExist returns true if the error is caused by a not existing file.
|
|
|
|
func (be *s3) IsNotExist(err error) bool {
|
|
|
|
debug.Log("IsNotExist(%T, %#v)", err, err)
|
2017-05-31 19:23:01 +00:00
|
|
|
return os.IsNotExist(err)
|
2017-05-15 21:37:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Join combines path components with slashes.
|
|
|
|
func (be *s3) Join(p ...string) string {
|
|
|
|
return path.Join(p...)
|
|
|
|
}
|
|
|
|
|
|
|
|
type fileInfo struct {
|
|
|
|
name string
|
|
|
|
size int64
|
|
|
|
mode os.FileMode
|
|
|
|
modTime time.Time
|
|
|
|
isDir bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fi fileInfo) Name() string { return fi.name } // base name of the file
|
|
|
|
func (fi fileInfo) Size() int64 { return fi.size } // length in bytes for regular files; system-dependent for others
|
|
|
|
func (fi fileInfo) Mode() os.FileMode { return fi.mode } // file mode bits
|
|
|
|
func (fi fileInfo) ModTime() time.Time { return fi.modTime } // modification time
|
|
|
|
func (fi fileInfo) IsDir() bool { return fi.isDir } // abbreviation for Mode().IsDir()
|
|
|
|
func (fi fileInfo) Sys() interface{} { return nil } // underlying data source (can return nil)
|
|
|
|
|
|
|
|
// ReadDir returns the entries for a directory.
|
|
|
|
func (be *s3) ReadDir(dir string) (list []os.FileInfo, err error) {
|
|
|
|
debug.Log("ReadDir(%v)", dir)
|
|
|
|
|
|
|
|
// make sure dir ends with a slash
|
|
|
|
if dir[len(dir)-1] != '/' {
|
|
|
|
dir += "/"
|
|
|
|
}
|
|
|
|
|
|
|
|
done := make(chan struct{})
|
|
|
|
defer close(done)
|
|
|
|
|
|
|
|
for obj := range be.client.ListObjects(be.bucketname, dir, false, done) {
|
|
|
|
if obj.Key == "" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
name := strings.TrimPrefix(obj.Key, dir)
|
|
|
|
if name == "" {
|
|
|
|
return nil, errors.Errorf("invalid key name %v, removing prefix %v yielded empty string", obj.Key, dir)
|
|
|
|
}
|
|
|
|
entry := fileInfo{
|
|
|
|
name: name,
|
|
|
|
size: obj.Size,
|
|
|
|
modTime: obj.LastModified,
|
|
|
|
}
|
|
|
|
|
|
|
|
if name[len(name)-1] == '/' {
|
|
|
|
entry.isDir = true
|
|
|
|
entry.mode = os.ModeDir | 0755
|
|
|
|
entry.name = name[:len(name)-1]
|
|
|
|
} else {
|
|
|
|
entry.mode = 0644
|
|
|
|
}
|
|
|
|
|
|
|
|
list = append(list, entry)
|
|
|
|
}
|
|
|
|
|
|
|
|
return list, nil
|
|
|
|
}
|
|
|
|
|
2015-05-13 17:48:52 +00:00
|
|
|
// Location returns this backend's location (the bucket name).
|
2016-01-26 21:19:10 +00:00
|
|
|
func (be *s3) Location() string {
|
2015-11-06 21:31:59 +00:00
|
|
|
return be.bucketname
|
2015-05-10 15:20:58 +00:00
|
|
|
}
|
|
|
|
|
2017-05-13 21:55:22 +00:00
|
|
|
// getRemainingSize returns number of bytes remaining. If it is not possible to
|
|
|
|
// determine the size, panic() is called.
|
|
|
|
func getRemainingSize(rd io.Reader) (size int64, err error) {
|
2017-05-14 18:36:26 +00:00
|
|
|
type Sizer interface {
|
|
|
|
Size() int64
|
|
|
|
}
|
|
|
|
|
|
|
|
type Lenner interface {
|
|
|
|
Len() int
|
|
|
|
}
|
|
|
|
|
2017-05-13 21:55:22 +00:00
|
|
|
if r, ok := rd.(Lenner); ok {
|
|
|
|
size = int64(r.Len())
|
|
|
|
} else if r, ok := rd.(Sizer); ok {
|
|
|
|
size = r.Size()
|
|
|
|
} else if f, ok := rd.(*os.File); ok {
|
|
|
|
fi, err := f.Stat()
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
|
|
|
|
pos, err := f.Seek(0, io.SeekCurrent)
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
|
|
|
|
size = fi.Size() - pos
|
|
|
|
} else {
|
|
|
|
panic(fmt.Sprintf("Save() got passed a reader without a method to determine the data size, type is %T", rd))
|
|
|
|
}
|
|
|
|
return size, nil
|
|
|
|
}
|
|
|
|
|
2017-05-13 22:09:49 +00:00
|
|
|
// preventCloser wraps an io.Reader to run a function instead of the original Close() function.
|
|
|
|
type preventCloser struct {
|
|
|
|
io.Reader
|
|
|
|
f func()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (wr preventCloser) Close() error {
|
|
|
|
wr.f()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-01-24 00:15:35 +00:00
|
|
|
// Save stores data in the backend at the handle.
|
2017-01-22 21:01:12 +00:00
|
|
|
func (be *s3) Save(h restic.Handle, rd io.Reader) (err error) {
|
2016-01-24 00:15:35 +00:00
|
|
|
if err := h.Valid(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-04-11 20:04:18 +00:00
|
|
|
objName := be.Filename(h)
|
2017-05-13 21:55:22 +00:00
|
|
|
size, err := getRemainingSize(rd)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2017-05-13 21:17:10 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 17:18:47 +00:00
|
|
|
debug.Log("Save %v at %v", h, objName)
|
|
|
|
|
2016-01-24 20:13:24 +00:00
|
|
|
// Check key does not already exist
|
2016-02-15 17:47:10 +00:00
|
|
|
_, err = be.client.StatObject(be.bucketname, objName)
|
2016-01-24 20:13:24 +00:00
|
|
|
if err == nil {
|
2016-09-27 20:35:08 +00:00
|
|
|
debug.Log("%v already exists", h)
|
2016-01-24 20:13:24 +00:00
|
|
|
return errors.New("key already exists")
|
|
|
|
}
|
|
|
|
|
2016-01-24 00:15:35 +00:00
|
|
|
<-be.connChan
|
|
|
|
|
2017-05-13 22:09:49 +00:00
|
|
|
// wrap the reader so that net/http client cannot close the reader, return
|
|
|
|
// the token instead.
|
|
|
|
rd = preventCloser{
|
|
|
|
Reader: rd,
|
|
|
|
f: func() {
|
|
|
|
debug.Log("Close()")
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-05-13 21:17:10 +00:00
|
|
|
debug.Log("PutObject(%v, %v)", be.bucketname, objName)
|
|
|
|
coreClient := minio.Core{be.client}
|
|
|
|
info, err := coreClient.PutObject(be.bucketname, objName, size, rd, nil, nil, nil)
|
|
|
|
|
|
|
|
// return token
|
|
|
|
be.connChan <- struct{}{}
|
|
|
|
debug.Log("%v -> %v bytes, err %#v", objName, info.Size, err)
|
2016-01-24 00:15:35 +00:00
|
|
|
|
2016-08-29 19:54:50 +00:00
|
|
|
return errors.Wrap(err, "client.PutObject")
|
2016-01-24 00:15:35 +00:00
|
|
|
}
|
|
|
|
|
2017-02-10 18:25:50 +00:00
|
|
|
// wrapReader wraps an io.ReadCloser to run an additional function on Close.
|
|
|
|
type wrapReader struct {
|
|
|
|
io.ReadCloser
|
|
|
|
f func()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (wr wrapReader) Close() error {
|
|
|
|
err := wr.ReadCloser.Close()
|
|
|
|
wr.f()
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-01-23 17:11:10 +00:00
|
|
|
// Load returns a reader that yields the contents of the file at h at the
|
2017-01-22 21:01:12 +00:00
|
|
|
// given offset. If length is nonzero, only a portion of the file is
|
|
|
|
// returned. rd must be closed after use.
|
2017-01-23 17:11:10 +00:00
|
|
|
func (be *s3) Load(h restic.Handle, length int, offset int64) (io.ReadCloser, error) {
|
2017-04-17 17:18:47 +00:00
|
|
|
debug.Log("Load %v, length %v, offset %v from %v", h, length, offset, be.Filename(h))
|
2017-01-22 21:01:12 +00:00
|
|
|
if err := h.Valid(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if offset < 0 {
|
|
|
|
return nil, errors.New("offset is negative")
|
|
|
|
}
|
|
|
|
|
|
|
|
if length < 0 {
|
|
|
|
return nil, errors.Errorf("invalid length %d", length)
|
|
|
|
}
|
|
|
|
|
2017-04-11 20:04:18 +00:00
|
|
|
objName := be.Filename(h)
|
2017-01-22 21:01:12 +00:00
|
|
|
|
2017-02-10 19:49:37 +00:00
|
|
|
// get token for connection
|
2017-01-22 21:01:12 +00:00
|
|
|
<-be.connChan
|
|
|
|
|
2017-05-13 19:18:14 +00:00
|
|
|
byteRange := fmt.Sprintf("bytes=%d-", offset)
|
|
|
|
if length > 0 {
|
|
|
|
byteRange = fmt.Sprintf("bytes=%d-%d", offset, offset+int64(length)-1)
|
2017-01-22 21:01:12 +00:00
|
|
|
}
|
2017-05-13 19:18:14 +00:00
|
|
|
headers := minio.NewGetReqHeaders()
|
|
|
|
headers.Add("Range", byteRange)
|
|
|
|
debug.Log("Load(%v) send range %v", h, byteRange)
|
2017-01-22 21:01:12 +00:00
|
|
|
|
2017-05-13 19:18:14 +00:00
|
|
|
coreClient := minio.Core{be.client}
|
|
|
|
rd, _, err := coreClient.GetObject(be.bucketname, objName, headers)
|
2017-05-13 22:09:59 +00:00
|
|
|
if err != nil {
|
|
|
|
// return token
|
|
|
|
be.connChan <- struct{}{}
|
|
|
|
return nil, err
|
|
|
|
}
|
2017-01-22 21:01:12 +00:00
|
|
|
|
2017-05-13 22:09:59 +00:00
|
|
|
closeRd := wrapReader{
|
|
|
|
ReadCloser: rd,
|
|
|
|
f: func() {
|
|
|
|
debug.Log("Close()")
|
|
|
|
// return token
|
|
|
|
be.connChan <- struct{}{}
|
|
|
|
},
|
|
|
|
}
|
2017-01-22 21:01:12 +00:00
|
|
|
|
2017-05-13 22:09:59 +00:00
|
|
|
return closeRd, err
|
2017-01-22 21:01:12 +00:00
|
|
|
}
|
|
|
|
|
2016-01-23 22:27:58 +00:00
|
|
|
// Stat returns information about a blob.
|
2017-01-22 21:01:12 +00:00
|
|
|
func (be *s3) Stat(h restic.Handle) (bi restic.FileInfo, err error) {
|
2016-09-27 20:35:08 +00:00
|
|
|
debug.Log("%v", h)
|
2016-08-21 14:15:24 +00:00
|
|
|
|
2017-04-11 20:04:18 +00:00
|
|
|
objName := be.Filename(h)
|
2016-08-21 14:15:24 +00:00
|
|
|
var obj *minio.Object
|
|
|
|
|
2016-02-15 17:47:10 +00:00
|
|
|
obj, err = be.client.GetObject(be.bucketname, objName)
|
2016-01-23 22:27:58 +00:00
|
|
|
if err != nil {
|
2016-09-27 20:35:08 +00:00
|
|
|
debug.Log("GetObject() err %v", err)
|
2016-08-31 20:39:36 +00:00
|
|
|
return restic.FileInfo{}, errors.Wrap(err, "client.GetObject")
|
2016-01-23 22:27:58 +00:00
|
|
|
}
|
|
|
|
|
2016-08-21 14:15:24 +00:00
|
|
|
// make sure that the object is closed properly.
|
|
|
|
defer func() {
|
|
|
|
e := obj.Close()
|
|
|
|
if err == nil {
|
2016-08-29 19:54:50 +00:00
|
|
|
err = errors.Wrap(e, "Close")
|
2016-08-21 14:15:24 +00:00
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2016-01-23 22:27:58 +00:00
|
|
|
fi, err := obj.Stat()
|
|
|
|
if err != nil {
|
2016-09-27 20:35:08 +00:00
|
|
|
debug.Log("Stat() err %v", err)
|
2016-08-31 20:39:36 +00:00
|
|
|
return restic.FileInfo{}, errors.Wrap(err, "Stat")
|
2016-01-23 22:27:58 +00:00
|
|
|
}
|
|
|
|
|
2016-08-31 20:39:36 +00:00
|
|
|
return restic.FileInfo{Size: fi.Size}, nil
|
2016-01-23 22:27:58 +00:00
|
|
|
}
|
|
|
|
|
2015-05-10 15:20:58 +00:00
|
|
|
// Test returns true if a blob of the given type and name exists in the backend.
|
2017-01-25 16:48:35 +00:00
|
|
|
func (be *s3) Test(h restic.Handle) (bool, error) {
|
2015-05-10 15:20:58 +00:00
|
|
|
found := false
|
2017-04-11 20:04:18 +00:00
|
|
|
objName := be.Filename(h)
|
2016-02-15 17:47:10 +00:00
|
|
|
_, err := be.client.StatObject(be.bucketname, objName)
|
2015-08-26 11:25:05 +00:00
|
|
|
if err == nil {
|
2015-05-10 15:20:58 +00:00
|
|
|
found = true
|
|
|
|
}
|
|
|
|
|
|
|
|
// If error, then not found
|
|
|
|
return found, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove removes the blob with the given name and type.
|
2017-01-25 16:48:35 +00:00
|
|
|
func (be *s3) Remove(h restic.Handle) error {
|
2017-04-11 20:04:18 +00:00
|
|
|
objName := be.Filename(h)
|
2016-02-15 17:47:10 +00:00
|
|
|
err := be.client.RemoveObject(be.bucketname, objName)
|
2017-04-17 17:18:47 +00:00
|
|
|
debug.Log("Remove(%v) at %v -> err %v", h, objName, err)
|
2016-08-29 19:54:50 +00:00
|
|
|
return errors.Wrap(err, "client.RemoveObject")
|
2015-05-10 15:20:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// List returns a channel that yields all names of blobs of type t. A
|
|
|
|
// goroutine is started for this. If the channel done is closed, sending
|
|
|
|
// stops.
|
2016-08-31 20:39:36 +00:00
|
|
|
func (be *s3) List(t restic.FileType, done <-chan struct{}) <-chan string {
|
2016-09-27 20:35:08 +00:00
|
|
|
debug.Log("listing %v", t)
|
2015-05-10 15:20:58 +00:00
|
|
|
ch := make(chan string)
|
|
|
|
|
2017-04-11 20:04:18 +00:00
|
|
|
prefix := be.Dirname(restic.Handle{Type: t})
|
2015-05-10 15:20:58 +00:00
|
|
|
|
2017-05-15 21:37:02 +00:00
|
|
|
// make sure prefix ends with a slash
|
|
|
|
if prefix[len(prefix)-1] != '/' {
|
|
|
|
prefix += "/"
|
|
|
|
}
|
|
|
|
|
2015-12-28 23:27:29 +00:00
|
|
|
listresp := be.client.ListObjects(be.bucketname, prefix, true, done)
|
2015-05-13 17:48:52 +00:00
|
|
|
|
2015-05-10 15:20:58 +00:00
|
|
|
go func() {
|
|
|
|
defer close(ch)
|
2015-11-06 21:31:59 +00:00
|
|
|
for obj := range listresp {
|
2015-12-28 23:27:29 +00:00
|
|
|
m := strings.TrimPrefix(obj.Key, prefix)
|
2015-05-10 15:20:58 +00:00
|
|
|
if m == "" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
select {
|
2017-05-31 19:22:55 +00:00
|
|
|
case ch <- path.Base(m):
|
2015-05-10 15:20:58 +00:00
|
|
|
case <-done:
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
return ch
|
|
|
|
}
|
|
|
|
|
2015-12-06 22:21:48 +00:00
|
|
|
// Remove keys for a specified backend type.
|
2016-08-31 20:39:36 +00:00
|
|
|
func (be *s3) removeKeys(t restic.FileType) error {
|
2015-12-06 22:21:48 +00:00
|
|
|
done := make(chan struct{})
|
|
|
|
defer close(done)
|
2016-08-31 20:39:36 +00:00
|
|
|
for key := range be.List(restic.DataFile, done) {
|
2017-01-25 16:48:35 +00:00
|
|
|
err := be.Remove(restic.Handle{Type: restic.DataFile, Name: key})
|
2015-12-06 22:21:48 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2015-06-14 13:02:29 +00:00
|
|
|
}
|
2015-12-06 22:21:48 +00:00
|
|
|
|
|
|
|
return nil
|
2015-06-14 13:02:29 +00:00
|
|
|
}
|
|
|
|
|
2015-12-19 12:23:05 +00:00
|
|
|
// Delete removes all restic keys in the bucket. It will not remove the bucket itself.
|
2016-01-26 21:19:10 +00:00
|
|
|
func (be *s3) Delete() error {
|
2016-08-31 20:39:36 +00:00
|
|
|
alltypes := []restic.FileType{
|
|
|
|
restic.DataFile,
|
|
|
|
restic.KeyFile,
|
|
|
|
restic.LockFile,
|
|
|
|
restic.SnapshotFile,
|
|
|
|
restic.IndexFile}
|
2015-12-06 22:21:48 +00:00
|
|
|
|
|
|
|
for _, t := range alltypes {
|
|
|
|
err := be.removeKeys(t)
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-25 16:48:35 +00:00
|
|
|
return be.Remove(restic.Handle{Type: restic.ConfigFile})
|
2015-05-10 15:20:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Close does nothing
|
2016-01-26 21:19:10 +00:00
|
|
|
func (be *s3) Close() error { return nil }
|