Repository: rclone/rclone (language: go)

Issue:
jottacloud: metadata isn't set properly on server side copy and move
In 41b1250eafcb8018160659a68f22f2e31e50780c we added tests for correct behaviour for or Metadata on server side Move and Copy

At this point the integration tests for Jottacloud started failing

```
"go test -v -timeout 1h0m0s -remote TestJottacloud: -verbose -test.run '^TestIntegration$/^FsMkdir$/^FsPutFiles$/^FsCopy$/^Metadata$|^TestIntegration$/^FsMkdir$/^FsPutFiles$/^FsMove$/^Metadata$'" - Starting (try 5/5)
```

giving

```
=== RUN   TestIntegration/FsMkdir/FsPutFiles/FsCopy/Metadata
    fstest.go:122: 
        	Error Trace:	/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:122
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:127
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:146
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:190
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:303
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:333
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:339
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstests/fstests.go:1310
        	Error:      	Should be true
        	Test:       	TestIntegration/FsMkdir/FsPutFiles/FsCopy/Metadata
        	Messages:   	test metadata copied.txt: Modification time difference too big |9456h0m0.499999999s| > 1s (want 2004-03-03 04:05:06.499999999 +0000 UTC vs got 2003-02-03 04:05:06 +0000 UTC) (precision 1s)
    fstest.go:122: 
        	Error Trace:	/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:122
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:606
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstests/fstests.go:1313
        	Error:      	Should be true
        	Test:       	TestIntegration/FsMkdir/FsPutFiles/FsCopy/Metadata
        	Messages:   	test metadata copied.txt: Modification time difference too big |9456h0m0.499999999s| > 1s (want 2004-03-03 04:05:06.499999999 +0000 UTC vs got 2003-02-03 04:05:06 +0000 UTC) (precision 1s)
    fstest.go:122: 
        	Error Trace:	/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:122
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:606
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstests/fstests.go:1315
        	Error:      	Should be true
        	Test:       	TestIntegration/FsMkdir/FsPutFiles/FsCopy/Metadata
        	Messages:   	test metadata copied.txt: Modification time difference too big |9456h0m0.499999999s| > 1s (want 2004-03-03 04:05:06.499999999 +0000 UTC vs got 2003-02-03 04:05:06 +0000 UTC) (precision 1s)
```

and

```
=== RUN   TestIntegration/FsMkdir/FsPutFiles/FsMove/Metadata
    fstest.go:122: 
        	Error Trace:	/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:122
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:127
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:146
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:190
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:303
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:333
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:339
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstests/fstests.go:1418
        	Error:      	Should be true
        	Test:       	TestIntegration/FsMkdir/FsPutFiles/FsMove/Metadata
        	Messages:   	test metadata moved.txt: Modification time difference too big |9456h0m0.499999999s| > 1s (want 2004-03-03 04:05:06.499999999 +0000 UTC vs got 2003-02-03 04:05:06 +0000 UTC) (precision 1s)
    fstest.go:122: 
        	Error Trace:	/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:122
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:606
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstests/fstests.go:1421
        	Error:      	Should be true
        	Test:       	TestIntegration/FsMkdir/FsPutFiles/FsMove/Metadata
        	Messages:   	test metadata moved.txt: Modification time difference too big |9456h0m0.499999999s| > 1s (want 2004-03-03 04:05:06.499999999 +0000 UTC vs got 2003-02-03 04:05:06 +0000 UTC) (precision 1s)
    fstest.go:122: 
        	Error Trace:	/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:122
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:606
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstests/fstests.go:1423
        	Error:      	Should be true
        	Test:       	TestIntegration/FsMkdir/FsPutFiles/FsMove/Metadata
        	Messages:   	test metadata moved.txt: Modification time difference too big |9456h0m0.499999999s| > 1s (want 2004-03-03 04:05:06.499999999 +0000 UTC vs got 2003-02-03 04:05:06 +0000 UTC) (precision 1s)
```

These are caused by the jottacloud backend not picking up metadata set by --metadata-set and the metadata mapper.

Similar fixes were made for google drive: 9f2ce2c7fc330f6441749a3e51325189e5001d48 and local: 6e85a39e9997189d1b828b49a2dc8049c67ad138

@albertony do you fancy taking a look at this since you added the metadata support to the jotta backend? Thank you

#### How to use GitHub

* Please use the 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to show that you are affected by the same issue.
* Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
* Subscribe to receive notifications on status change and new comments.



Discussion / hints:
@albertony 

In the integration tests this morning it looks like this test failed

```
=== RUN   TestIntegration/FsMkdir/FsPutFiles/FsMove/Metadata
    fstest.go:122: 
        	Error Trace:	/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:122
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:127
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:146
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:190
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:303
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:333
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:339
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstests/fstests.go:1418
        	Error:      	Should be true
        	Test:       	TestIntegration/FsMkdir/FsPutFiles/FsMove/Metadata
        	Messages:   	test metadata moved.txt: Modification time difference too big |9456h0m0.499999999s| > 1s (want 2004-03-03 04:05:06.499999999 +0000 UTC vs got 2003-02-03 04:05:06 +0000 UTC) (precision 1s)
    fstest.go:122: 
        	Error Trace:	/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:122
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:606
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstests/fstests.go:1421
        	Error:      	Should be true
        	Test:       	TestIntegration/FsMkdir/FsPutFiles/FsMove/Metadata
        	Messages:   	test metadata moved.txt: Modification time difference too big |9456h0m0.499999999s| > 1s (want 2004-03-03 04:05:06.499999999 +0000 UTC vs got 2003-02-03 04:05:06 +0000 UTC) (precision 1s)
    fstest.go:122: 
        	Error Trace:	/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:122
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:606
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstests/fstests.go:1423
        	Error:      	Should be true
        	Test:       	TestIntegration/FsMkdir/FsPutFiles/FsMove/Metadata
        	Messages:   	test metadata moved.txt: Modification time difference too big |9456h0m0.499999999s| > 1s (want 2004-03-03 04:05:06.499999999 +0000 UTC vs got 2003-02-03 04:05:06 +0000 UTC) (precision 1s)
```

Which is weird since the code looked OK and I assume you tested it.

Any ideas?
I started looking into it 2,5 minutes ago.. :)
Ah, its because it takes another path: `DirMove`.

And that's more challenging to fix, isn't it? I mean, should `--metadata-set` apply to all files, or only the top level dir? And why does both onedrive and local backends also have DirMove implementations, but neither of them seemed to need additional handling for metadata?
When implementing the tests I decided to bail on DirMove as it was too difficult!

So I'm not sure why this is failing as it wasn't my intention that DirMove would need to be changed.
I'm going to re-open this as the Move tests are still failing in the same way :-(

From today's integration test run

```
"go test -v -timeout 1h0m0s -remote TestJottacloud: -verbose -test.run '^TestIntegration$/^FsMkdir$/^FsPutFiles$/^FsMove$/^Metadata$'" - Starting (try 5/5)
=== RUN   TestIntegration
    fstests.go:442: Using remote "TestJottacloud:"
2024/09/07 01:05:39 DEBUG : Creating backend with remote "TestJottacloud:rclone-test-tacekit9kuqo"
2024/09/07 01:05:39 DEBUG : Using config file from "/home/rclone/.rclone.conf"
=== RUN   TestIntegration/FsMkdir
=== RUN   TestIntegration/FsMkdir/FsPutFiles
=== RUN   TestIntegration/FsMkdir/FsPutFiles/FsMove
=== RUN   TestIntegration/FsMkdir/FsPutFiles/FsMove/Metadata
    fstest.go:121: 
        	Error Trace:	/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:121
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:126
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:145
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:189
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:302
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:332
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:338
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstests/fstests.go:1434
        	Error:      	Should be true
        	Test:       	TestIntegration/FsMkdir/FsPutFiles/FsMove/Metadata
        	Messages:   	test metadata moved.txt: Modification time difference too big |9456h0m0.499999999s| > 1s (want 2004-03-03 04:05:06.499999999 +0000 UTC vs got 2003-02-03 04:05:06 +0000 UTC) (precision 1s)
    fstest.go:121: 
        	Error Trace:	/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:121
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:605
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstests/fstests.go:1437
        	Error:      	Should be true
        	Test:       	TestIntegration/FsMkdir/FsPutFiles/FsMove/Metadata
        	Messages:   	test metadata moved.txt: Modification time difference too big |9456h0m0.499999999s| > 1s (want 2004-03-03 04:05:06.499999999 +0000 UTC vs got 2003-02-03 04:05:06 +0000 UTC) (precision 1s)
    fstest.go:121: 
        	Error Trace:	/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:121
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstest.go:605
        	            				/home/rclone/go/src/github.com/rclone/rclone/fstest/fstests/fstests.go:1439
        	Error:      	Should be true
        	Test:       	TestIntegration/FsMkdir/FsPutFiles/FsMove/Metadata
        	Messages:   	test metadata moved.txt: Modification time difference too big |9456h0m0.499999999s| > 1s (want 2004-03-03 04:05:06.499999999 +0000 UTC vs got 2003-02-03 04:05:06 +0000 UTC) (precision 1s)
```

Fix patch:
diff --git a/backend/jottacloud/jottacloud.go b/backend/jottacloud/jottacloud.go
index 04e4bca10e650..8ad457c743898 100644
--- a/backend/jottacloud/jottacloud.go
+++ b/backend/jottacloud/jottacloud.go
@@ -1555,7 +1555,7 @@ func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object,
 	}
 	info, err := f.copyOrMove(ctx, "mv", srcObj.filePath(), remote)
 
-	if err != nil && meta != nil {
+	if err == nil && meta != nil {
 		createTime, createTimeMeta := srcObj.parseFsMetadataTime(meta, "btime")
 		if !createTimeMeta {
 			createTime = srcObj.createTime


Test patch: