Skip to content

Commit 86ada97

Browse files
authored
Merge pull request #17325 from iterate-ch/bugfix/MD-24072-versionid-quickxorhash
Use QuickXorHash for version identifier as ctag apparently changes on…
2 parents 2db6361 + 3d0b0a7 commit 86ada97

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

onedrive/src/main/java/ch/cyberduck/core/onedrive/features/GraphAttributesFinderFeature.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
import org.nuxeo.onedrive.client.OneDriveAPIException;
3333
import org.nuxeo.onedrive.client.types.DriveItem;
3434
import org.nuxeo.onedrive.client.types.DriveItemVersion;
35+
import org.nuxeo.onedrive.client.types.File;
3536
import org.nuxeo.onedrive.client.types.FileSystemInfo;
37+
import org.nuxeo.onedrive.client.types.Hashes;
3638
import org.nuxeo.onedrive.client.types.Publication;
3739

3840
import java.io.IOException;
@@ -89,7 +91,13 @@ private DriveItem.Metadata toMetadata(final Path file, final DriveItem item) thr
8991
public PathAttributes toAttributes(final DriveItem.Metadata metadata) {
9092
final PathAttributes attributes = new PathAttributes();
9193
attributes.setETag(metadata.getETag());
92-
attributes.setVersionId(metadata.getcTag());
94+
final File file = metadata.getFile();
95+
if(file != null) {
96+
final Hashes hashes = file.getHashes();
97+
if(hashes != null) {
98+
attributes.setVersionId(hashes.getQuickXorHash());
99+
}
100+
}
93101
Optional<DescriptiveUrl> webUrl = getWebUrl(metadata);
94102
if(metadata.isPackage()) {
95103
webUrl.ifPresent(url -> attributes.setSize(UrlFileWriterFactory.get().write(url).getBytes(Charset.defaultCharset()).length));

onedrive/src/test/java/ch/cyberduck/core/onedrive/GraphAttributesFinderFeatureTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void testFindDirectory() throws Exception {
7979
assertNotEquals(-1L, attributes.getCreationDate());
8080
assertNotEquals(-1L, attributes.getModificationDate());
8181
assertNotNull(attributes.getETag());
82-
assertNotNull(attributes.getVersionId());
82+
assertNull(attributes.getVersionId());
8383
assertNotNull(attributes.getLink());
8484
assertNotNull(attributes.getFileId());
8585
new GraphDeleteFeature(session, fileid).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());

onedrive/src/test/java/ch/cyberduck/core/onedrive/GraphMoveFeatureTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public void testRename() throws BackgroundException {
8383
final Path target = move.move(file, rename, status, new Delete.DisabledCallback(), new DisabledConnectionCallback());
8484
assertEquals(attributes, target.attributes());
8585
assertEquals(attributes.getFileId(), target.attributes().getFileId());
86+
assertEquals(attributes.getVersionId(), target.attributes().getVersionId());
8687
assertNotEquals(attributes.getETag(), attributesFinder.find(rename).getETag());
8788
assertEquals(target.attributes().getETag(), attributesFinder.find(rename).getETag());
8889
delete.delete(Collections.singletonList(rename), new DisabledLoginCallback(), new Delete.DisabledCallback());
@@ -111,6 +112,7 @@ public void testMove() throws BackgroundException {
111112
assertNotNull(renamedAttributes);
112113
assertEquals(attributes, renamedAttributes);
113114
assertNotEquals(attributes.getETag(), renamedAttributes.getETag());
115+
assertEquals(attributes.getVersionId(), renamedAttributes.getVersionId());
114116
assertEquals(target.attributes().getETag(), renamedAttributes.getETag());
115117

116118
delete.delete(Collections.singletonList(targetDirectory), new DisabledLoginCallback(), new Delete.DisabledCallback());

0 commit comments

Comments
 (0)