From 89b53a7e52c31abff2ab9e1f38055ce493bcb357 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Tue, 15 Nov 2022 16:55:05 +0100 Subject: [PATCH] ls: Fix listing versions when the system clock is off (#4370) --- cmd/client-s3.go | 6 +----- cmd/ls-main.go | 3 --- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/cmd/client-s3.go b/cmd/client-s3.go index 3d8f66d5..2b81d7cc 100644 --- a/cmd/client-s3.go +++ b/cmd/client-s3.go @@ -1759,10 +1759,6 @@ func (c *S3Client) listVersions(ctx context.Context, b, o string, isRecursive bo } func (c *S3Client) listVersionsRoutine(ctx context.Context, b, o string, isRecursive bool, timeRef time.Time, includeOlderVersions, withDeleteMarkers bool, objectInfoCh chan minio.ObjectInfo) { - if timeRef.IsZero() { - timeRef = time.Now().UTC() - } - var buckets []string if b == "" { bucketsInfo, err := c.api.ListBuckets(ctx) @@ -1797,7 +1793,7 @@ func (c *S3Client) listVersionsRoutine(ctx context.Context, b, o string, isRecur continue } - if objectVersion.LastModified.Before(timeRef) { + if timeRef.IsZero() || objectVersion.LastModified.Before(timeRef) { skipKey = objectVersion.Key // Skip if this is a delete marker and we are not asked to list it diff --git a/cmd/ls-main.go b/cmd/ls-main.go index b415faf4..23ebecfa 100644 --- a/cmd/ls-main.go +++ b/cmd/ls-main.go @@ -175,9 +175,6 @@ func checkListSyntax(ctx context.Context, cliCtx *cli.Context) ([]string, doList listZip := cliCtx.Bool("zip") timeRef := parseRewindFlag(cliCtx.String("rewind")) - if timeRef.IsZero() && withOlderVersions { - timeRef = time.Now().UTC() - } if listZip && (withOlderVersions || !timeRef.IsZero()) { fatalIf(errInvalidArgument().Trace(args...), "Zip file listing can only be performed on the latest version")