Skip to content

Commit

Permalink
fix: list object should return etag information when needed (#5013)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro authored Jul 23, 2024
1 parent 2ad3782 commit 26a877f
Showing 1 changed file with 37 additions and 35 deletions.
72 changes: 37 additions & 35 deletions pkg/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,14 @@ func (n *jfsObjects) listDirFactory() minio.ListDirFunc {
if root && (fi.Name() == metaBucket || fi.Name() == minio.MinioMetaBucket) {
continue
}
if stat, ok := fi.(*fs.FileStat); ok && stat.IsSymlink() {
var err syscall.Errno
p := n.path(bucket, prefixDir, fi.Name())
if fi, err = n.fs.Stat(mctx, p); err != 0 {
logger.Errorf("stat %s: %s", p, err)
continue
}
}
entry := &minio.Entry{Name: fi.Name(),
Info: &minio.ObjectInfo{
Bucket: bucket,
Expand All @@ -343,14 +351,7 @@ func (n *jfsObjects) listDirFactory() minio.ListDirFunc {
AccTime: fi.ModTime(),
},
}
if stat, ok := fi.(*fs.FileStat); ok && stat.IsSymlink() {
var err syscall.Errno
p := n.path(bucket, prefixDir, fi.Name())
if fi, err = n.fs.Stat(mctx, p); err != 0 {
logger.Errorf("stat %s: %s", p, err)
continue
}
}

if fi.IsDir() {
entry.Name += sep
entry.Info.Size = 0
Expand Down Expand Up @@ -381,37 +382,38 @@ 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,
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,
ModTime: now,
Size: 0,
IsDir: false,
AccTime: now,
}
eno = 0
}
eno = 0
}

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

0 comments on commit 26a877f

Please sign in to comment.