|
|
@ -22,7 +22,6 @@ import ( |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"hash" |
|
|
|
"hash" |
|
|
|
"io" |
|
|
|
"io" |
|
|
|
"io/ioutil" |
|
|
|
|
|
|
|
"net/http" |
|
|
|
"net/http" |
|
|
|
|
|
|
|
|
|
|
|
"strings" |
|
|
|
"strings" |
|
|
@ -460,13 +459,23 @@ func (l *b2Objects) GetObjectInfo(ctx context.Context, bucket string, object str |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return objInfo, err |
|
|
|
return objInfo, err |
|
|
|
} |
|
|
|
} |
|
|
|
f, err := bkt.DownloadFileByName(l.ctx, object, 0, 1) |
|
|
|
|
|
|
|
|
|
|
|
f, _, err := bkt.ListFileNames(l.ctx, 1, object, "", "") |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
logger.LogIf(ctx, err) |
|
|
|
logger.LogIf(ctx, err) |
|
|
|
return objInfo, b2ToObjectError(err, bucket, object) |
|
|
|
return objInfo, b2ToObjectError(err, bucket, object) |
|
|
|
} |
|
|
|
} |
|
|
|
f.Close() |
|
|
|
|
|
|
|
fi, err := bkt.File(f.ID, object).GetFileInfo(l.ctx) |
|
|
|
// B2's list will return the next item in the bucket if the object doesn't
|
|
|
|
|
|
|
|
// exist so we need to perform a name check too
|
|
|
|
|
|
|
|
if len(f) != 1 || (len(f) == 1 && f[0].Name != object) { |
|
|
|
|
|
|
|
return objInfo, minio.ObjectNotFound{ |
|
|
|
|
|
|
|
Bucket: bucket, |
|
|
|
|
|
|
|
Object: object, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fi, err := bkt.File(f[0].ID, object).GetFileInfo(l.ctx) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
logger.LogIf(ctx, err) |
|
|
|
logger.LogIf(ctx, err) |
|
|
|
return objInfo, b2ToObjectError(err, bucket, object) |
|
|
|
return objInfo, b2ToObjectError(err, bucket, object) |
|
|
@ -474,7 +483,7 @@ func (l *b2Objects) GetObjectInfo(ctx context.Context, bucket string, object str |
|
|
|
return minio.ObjectInfo{ |
|
|
|
return minio.ObjectInfo{ |
|
|
|
Bucket: bucket, |
|
|
|
Bucket: bucket, |
|
|
|
Name: object, |
|
|
|
Name: object, |
|
|
|
ETag: minio.ToS3ETag(f.ID), |
|
|
|
ETag: minio.ToS3ETag(f[0].ID), |
|
|
|
Size: fi.Size, |
|
|
|
Size: fi.Size, |
|
|
|
ModTime: fi.Timestamp, |
|
|
|
ModTime: fi.Timestamp, |
|
|
|
ContentType: fi.ContentType, |
|
|
|
ContentType: fi.ContentType, |
|
|
@ -595,14 +604,10 @@ func (l *b2Objects) DeleteObject(ctx context.Context, bucket string, object stri |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
reader, err := bkt.DownloadFileByName(l.ctx, object, 0, 1) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
// If we hide the file we'll conform to B2's versioning policy, it also
|
|
|
|
logger.LogIf(ctx, err) |
|
|
|
// saves an additional call to check if the file exists first
|
|
|
|
return b2ToObjectError(err, bucket, object) |
|
|
|
_, err = bkt.HideFile(l.ctx, object) |
|
|
|
} |
|
|
|
|
|
|
|
io.Copy(ioutil.Discard, reader) |
|
|
|
|
|
|
|
reader.Close() |
|
|
|
|
|
|
|
err = bkt.File(reader.ID, object).DeleteFileVersion(l.ctx) |
|
|
|
|
|
|
|
logger.LogIf(ctx, err) |
|
|
|
logger.LogIf(ctx, err) |
|
|
|
return b2ToObjectError(err, bucket, object) |
|
|
|
return b2ToObjectError(err, bucket, object) |
|
|
|
} |
|
|
|
} |
|
|
|