From 3bb9394ae538dbda808f5fb713525500b43e0a4d Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 1 Mar 2024 11:18:24 +0000 Subject: [PATCH] operations: fix TestMkdirModTime test This was failing on backends that didn't support metadata but did support setting directory modtimes. --- fs/operations/operations.go | 7 ++++--- fs/operations/operations_test.go | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/operations/operations.go b/fs/operations/operations.go index efb3c1f17..125608fcf 100644 --- a/fs/operations/operations.go +++ b/fs/operations/operations.go @@ -1015,11 +1015,12 @@ func MkdirMetadata(ctx context.Context, f fs.Fs, dir string, metadata fs.Metadat // MkdirModTime makes a destination directory or container with modtime // -// If the destination Fs doesn't support this it will fall back to -// Mkdir and in this case newDst will be nil. +// It will try to make the directory with MkdirMetadata and if that +// succeeds it will return a non-nil newDst. In all other cases newDst +// will be nil. // // If the directory was created with MkDir then it will attempt to use -// Fs.DirSetModTime if available. +// Fs.DirSetModTime to update the directory modtime if available. func MkdirModTime(ctx context.Context, f fs.Fs, dir string, modTime time.Time) (newDst fs.Directory, err error) { logName := fs.LogDirName(f, dir) if SkipDestructive(ctx, logName, "make directory") { diff --git a/fs/operations/operations_test.go b/fs/operations/operations_test.go index 6f55b09c0..3119ce185 100644 --- a/fs/operations/operations_test.go +++ b/fs/operations/operations_test.go @@ -1680,7 +1680,10 @@ func TestMkdirModTime(t *testing.T) { require.NoError(t, err) // Check the returned directory and one read from the listing - fstest.CheckDirModTime(ctx, t, r.Fremote, newDst, t2) + // newDst may be nil here depending on how the modtime was set + if newDst != nil { + fstest.CheckDirModTime(ctx, t, r.Fremote, newDst, t2) + } fstest.CheckDirModTime(ctx, t, r.Fremote, fstest.NewDirectory(ctx, t, r.Fremote, name), t2) }