summaryrefslogtreecommitdiff
path: root/fs.go
diff options
context:
space:
mode:
Diffstat (limited to 'fs.go')
-rw-r--r--fs.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/fs.go b/fs.go
index 1baa723..d704994 100644
--- a/fs.go
+++ b/fs.go
@@ -8,6 +8,7 @@ import (
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
+ "github.com/spf13/afero"
)
var (
@@ -97,7 +98,7 @@ func (fs *Fs) Stat(name string) (os.FileInfo, error) {
defer cancel()
info, err := fs.client.StatObject(ctx, fs.bucket, name, minio.GetObjectOptions{})
if err != nil {
- return nil, err
+ return nil, transformError(err)
}
return transformObjectInfo(info), nil
}
@@ -120,3 +121,18 @@ func (fs *Fs) Chtimes(name string, atime time.Time, mtime time.Time) error {
func (fs *Fs) contextWithTimeout() (context.Context, context.CancelFunc) {
return context.WithTimeout(context.Background(), fs.Timeout)
}
+
+func transformError(err error) error {
+ resp, ok := err.(minio.ErrorResponse)
+ if !ok {
+ return err
+ }
+
+ switch resp.Code {
+ case "NoSuchKey":
+ return afero.ErrFileNotFound
+ case "EntityTooLarge":
+ return afero.ErrTooLarge
+ }
+ return err
+}