Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: list object should return etag information when needed #5013

Merged
merged 3 commits into from
Jul 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading