Skip to content

Commit

Permalink
list object should return etag information when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro committed Jul 22, 2024
1 parent 61a0099 commit 5967148
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions pkg/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,43 +381,47 @@ func (n *jfsObjects) ListObjects(ctx context.Context, bucket, prefix, marker, de
return loi, err
}
getObjectInfo := func(ctx context.Context, bucket, object string, info *minio.ObjectInfo) (obj minio.ObjectInfo, err error) {
if info != nil && info.Size > 0 {
info.Name = object
return *info, nil
}
fi, eno := n.fs.Stat(mctx, n.path(bucket, object))
if eno == 0 {
size := fi.Size()
if fi.IsDir() {
size = 0
}
info = &minio.ObjectInfo{
Bucket: bucket,
ModTime: fi.ModTime(),
Size: size,
IsDir: fi.IsDir(),
AccTime: fi.ModTime(),
var eno syscall.Errno
if info == nil {
var fi *fs.FileStat
fi, eno = n.fs.Stat(mctx, n.path(bucket, object))
if eno == 0 {
size := fi.Size()
if fi.IsDir() {
size = 0
}
info = &minio.ObjectInfo{
Bucket: bucket,
Name: object,
ModTime: fi.ModTime(),
Size: size,
IsDir: fi.IsDir(),
AccTime: fi.ModTime(),
}
}
}

// replace links to external file systems with empty files
if eno == syscall.ENOTSUP {
now := time.Now()
info = &minio.ObjectInfo{
Bucket: bucket,
ModTime: now,
Size: 0,
IsDir: false,
AccTime: now,
// replace links to external file systems with empty files
if errors.Is(eno, syscall.ENOTSUP) {
now := time.Now()
info = &minio.ObjectInfo{
Bucket: bucket,
Name: object,
ModTime: now,
Size: 0,
IsDir: false,
AccTime: now,
}
eno = 0
}
eno = 0
}

if info == nil {
return obj, jfsToObjectErr(ctx, eno, bucket, object)
}
info.Name = object

var etag []byte
if n.gConf.KeepEtag && !strings.HasSuffix(object, sep) {
etag, _ := n.fs.GetXattr(mctx, n.path(bucket, object), s3Etag)
etag, _ = n.fs.GetXattr(mctx, n.path(bucket, object), s3Etag)
info.ETag = string(etag)
}
return *info, jfsToObjectErr(ctx, eno, bucket, object)
Expand Down

0 comments on commit 5967148

Please sign in to comment.