mirror of https://github.com/minio/minio.git
fs: Update object modtime when metadata is updated (#12818)
Follow S3 behavior of updating object modtime when object metadata is updated.
This commit is contained in:
parent
a78bc7bfdb
commit
20cacc3b04
|
@ -24,6 +24,7 @@ import (
|
||||||
pathutil "path"
|
pathutil "path"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/minio/minio/internal/lock"
|
"github.com/minio/minio/internal/lock"
|
||||||
"github.com/minio/minio/internal/logger"
|
"github.com/minio/minio/internal/logger"
|
||||||
|
@ -168,6 +169,25 @@ func fsStat(ctx context.Context, statLoc string) (os.FileInfo, error) {
|
||||||
return fi, nil
|
return fi, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fsTouch updates a file access & modtime with current time
|
||||||
|
func fsTouch(ctx context.Context, statLoc string) error {
|
||||||
|
if statLoc == "" {
|
||||||
|
logger.LogIf(ctx, errInvalidArgument)
|
||||||
|
return errInvalidArgument
|
||||||
|
}
|
||||||
|
if err := checkPathLength(statLoc); err != nil {
|
||||||
|
logger.LogIf(ctx, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
now := time.Now()
|
||||||
|
if err := os.Chtimes(statLoc, now, now); err != nil {
|
||||||
|
logger.LogIf(ctx, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Lookup if volume exists, returns volume attributes upon success.
|
// Lookup if volume exists, returns volume attributes upon success.
|
||||||
func fsStatVolume(ctx context.Context, volume string) (os.FileInfo, error) {
|
func fsStatVolume(ctx context.Context, volume string) (os.FileInfo, error) {
|
||||||
fi, err := fsStat(ctx, volume)
|
fi, err := fsStat(ctx, volume)
|
||||||
|
|
11
cmd/fs-v1.go
11
cmd/fs-v1.go
|
@ -682,8 +682,15 @@ func (fs *FSObjects) CopyObject(ctx context.Context, srcBucket, srcObject, dstBu
|
||||||
return oi, toObjectErr(err, srcBucket, srcObject)
|
return oi, toObjectErr(err, srcBucket, srcObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stat the file to get file size.
|
fsObjectPath := pathJoin(fs.fsPath, srcBucket, srcObject)
|
||||||
fi, err := fsStatFile(ctx, pathJoin(fs.fsPath, srcBucket, srcObject))
|
|
||||||
|
// Update object modtime
|
||||||
|
err = fsTouch(ctx, fsObjectPath)
|
||||||
|
if err != nil {
|
||||||
|
return oi, toObjectErr(err, srcBucket, srcObject)
|
||||||
|
}
|
||||||
|
// Stat the file to get object info
|
||||||
|
fi, err := fsStatFile(ctx, fsObjectPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return oi, toObjectErr(err, srcBucket, srcObject)
|
return oi, toObjectErr(err, srcBucket, srcObject)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue