mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
Use the B2 'list' endpoint to determine file ID (#8169)
- More effective deletion and checking for existence. - Rever Dockerfile. - Add a 'GOPROXY' to the Dockerfile to workaround Apache issues.
This commit is contained in:
parent
475df52a19
commit
a87fc7d09b
@ -5,6 +5,7 @@ LABEL maintainer="MinIO Inc <dev@min.io>"
|
|||||||
ENV GOPATH /go
|
ENV GOPATH /go
|
||||||
ENV CGO_ENABLED 0
|
ENV CGO_ENABLED 0
|
||||||
ENV GO111MODULE on
|
ENV GO111MODULE on
|
||||||
|
ENV GOPROXY https://proxy.golang.org
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
apk add --no-cache git && \
|
apk add --no-cache git && \
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user