From d8297da97cc51f9406eb8fc6677aa30a4cc60f9e Mon Sep 17 00:00:00 2001 From: David Kocher Date: Thu, 28 Mar 2024 14:28:05 +0100 Subject: [PATCH 1/2] Implement file id provider using reference id of node. --- .../cyberduck/core/CachingFileIdProvider.java | 2 +- .../core/CachingVersionIdProvider.java | 4 +- .../core/sds/SDSAttributesAdapter.java | 6 ++ .../cyberduck/core/sds/SDSNodeIdProvider.java | 68 +++++++++++++++++-- .../ch/cyberduck/core/sds/SDSSession.java | 3 + .../SDSDirectS3MultipartWriteFeatureTest.java | 1 + 6 files changed, 74 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/ch/cyberduck/core/CachingFileIdProvider.java b/core/src/main/java/ch/cyberduck/core/CachingFileIdProvider.java index 9cb7d1ed714..dc289dc2aec 100644 --- a/core/src/main/java/ch/cyberduck/core/CachingFileIdProvider.java +++ b/core/src/main/java/ch/cyberduck/core/CachingFileIdProvider.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public abstract class CachingFileIdProvider implements FileIdProvider { +public class CachingFileIdProvider implements FileIdProvider { private static final Logger log = LogManager.getLogger(CachingFileIdProvider.class); private final LRUCache cache diff --git a/core/src/main/java/ch/cyberduck/core/CachingVersionIdProvider.java b/core/src/main/java/ch/cyberduck/core/CachingVersionIdProvider.java index ee22d463bf4..06174628bbf 100644 --- a/core/src/main/java/ch/cyberduck/core/CachingVersionIdProvider.java +++ b/core/src/main/java/ch/cyberduck/core/CachingVersionIdProvider.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public abstract class CachingVersionIdProvider implements VersionIdProvider { +public class CachingVersionIdProvider implements VersionIdProvider { private static final Logger log = LogManager.getLogger(CachingVersionIdProvider.class); private final LRUCache cache @@ -31,7 +31,7 @@ public abstract class CachingVersionIdProvider implements VersionIdProvider { private final Protocol.Case sensitivity; - protected CachingVersionIdProvider(final Protocol.Case sensitivity) { + public CachingVersionIdProvider(final Protocol.Case sensitivity) { this.sensitivity = sensitivity; } diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSAttributesAdapter.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSAttributesAdapter.java index 87e0909b7f3..051b758dbcd 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSAttributesAdapter.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSAttributesAdapter.java @@ -47,6 +47,9 @@ public SDSAttributesAdapter(final SDSSession session) { @Override public PathAttributes toAttributes(final Node node) { final PathAttributes attributes = new PathAttributes(); + if(node.getReferenceId() != null) { + attributes.setFileId(String.valueOf(node.getReferenceId())); + } attributes.setVersionId(String.valueOf(node.getId())); attributes.setRevision(node.getBranchVersion()); if(node.isIsEncrypted() != null && !node.isIsEncrypted()) { @@ -109,6 +112,9 @@ public PathAttributes toAttributes(final Node node) { public PathAttributes toAttributes(final DeletedNode node) { final PathAttributes attributes = new PathAttributes(); attributes.setDuplicate(true); + if(node.getReferenceId() != null) { + attributes.setVersionId(String.valueOf(node.getReferenceId())); + } attributes.setVersionId(String.valueOf(node.getId())); attributes.setCreationDate(node.getCreatedAt() != null ? node.getCreatedAt().getMillis() : -1L); attributes.setModificationDate(node.getUpdatedAt() != null ? node.getUpdatedAt().getMillis() : -1L); diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSNodeIdProvider.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSNodeIdProvider.java index bfef0a45756..72a9c9a8615 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSNodeIdProvider.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSNodeIdProvider.java @@ -15,11 +15,13 @@ * GNU General Public License for more details. */ +import ch.cyberduck.core.CachingFileIdProvider; import ch.cyberduck.core.CachingVersionIdProvider; import ch.cyberduck.core.Path; import ch.cyberduck.core.URIEncoder; import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.exception.NotfoundException; +import ch.cyberduck.core.features.FileIdProvider; import ch.cyberduck.core.features.VersionIdProvider; import ch.cyberduck.core.preferences.HostPreferences; import ch.cyberduck.core.sds.io.swagger.client.ApiException; @@ -33,17 +35,26 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public class SDSNodeIdProvider extends CachingVersionIdProvider implements VersionIdProvider { +public class SDSNodeIdProvider implements FileIdProvider, VersionIdProvider { private static final Logger log = LogManager.getLogger(SDSNodeIdProvider.class); private static final UnicodeNormalizer normalizer = new NFCNormalizer(); private static final String ROOT_NODE_ID = "0"; private final SDSSession session; + /** + * Node id as file version + */ + private final CachingVersionIdProvider versions; + /** + * Reference id that is static across different file versions + */ + private final CachingFileIdProvider references; public SDSNodeIdProvider(final SDSSession session) { - super(session.getCaseSensitivity()); this.session = session; + this.versions = new CachingVersionIdProvider(session.getCaseSensitivity()); + this.references = new CachingFileIdProvider(session.getCaseSensitivity()); } @Override @@ -54,20 +65,61 @@ public String getVersionId(final Path file) throws BackgroundException { } return file.attributes().getVersionId(); } - final String cached = super.getVersionId(file); + final String cached = versions.getVersionId(file); if(cached != null) { if(log.isDebugEnabled()) { log.debug(String.format("Return cached versionid %s for file %s", cached, file)); } return cached; } - return this.getNodeId(file, new HostPreferences(session.getHost()).getInteger("sds.listing.chunksize")); + final Node node = this.getNode(file, new HostPreferences(session.getHost()).getInteger("sds.listing.chunksize")); + if(null == node) { + return ROOT_NODE_ID; + } + if(null != node.getId()) { + return String.valueOf(node.getId()); + } + return null; } - protected String getNodeId(final Path file, final int chunksize) throws BackgroundException { - if(file.isRoot()) { + @Override + public String getFileId(final Path file) throws BackgroundException { + if(file.isDirectory()) { + return null; + } + if(StringUtils.isNotBlank(file.attributes().getFileId())) { + if(log.isDebugEnabled()) { + log.debug(String.format("Return version %s from attributes for file %s", file.attributes().getFileId(), file)); + } + return file.attributes().getFileId(); + } + final String cached = references.getFileId(file); + if(cached != null) { + if(log.isDebugEnabled()) { + log.debug(String.format("Return cached versionid %s for file %s", cached, file)); + } + return cached; + } + final Node node = this.getNode(file, new HostPreferences(session.getHost()).getInteger("sds.listing.chunksize")); + if(null == node) { return ROOT_NODE_ID; } + if(null != node.getReferenceId()) { + return String.valueOf(node.getReferenceId()); + } + return null; + } + + @Override + public void clear() { + versions.clear(); + references.clear(); + } + + protected Node getNode(final Path file, final int chunksize) throws BackgroundException { + if(file.isRoot()) { + return null; + } try { final String type; if(file.isDirectory()) { @@ -101,7 +153,9 @@ protected String getNodeId(final Path file, final int chunksize) throws Backgrou if(log.isInfoEnabled()) { log.info(String.format("Return node %s for file %s", node.getId(), file)); } - return this.cache(file, node.getId().toString()); + versions.cache(file, node.getId().toString()); + references.cache(file, node.getReferenceId().toString()); + return node; } } offset += chunksize; diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSSession.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSSession.java index 2f14af332fe..66446c72dc1 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSSession.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSSession.java @@ -569,6 +569,9 @@ public T _getFeature(final Class type) { if(type == Delete.class) { return (T) new SDSThresholdDeleteFeature(this, nodeid); } + if(type == SDSNodeIdProvider.class) { + return (T) nodeid; + } if(type == VersionIdProvider.class) { return (T) nodeid; } diff --git a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSDirectS3MultipartWriteFeatureTest.java b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSDirectS3MultipartWriteFeatureTest.java index b68e8ce5dae..1bf4b7009e9 100644 --- a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSDirectS3MultipartWriteFeatureTest.java +++ b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSDirectS3MultipartWriteFeatureTest.java @@ -91,6 +91,7 @@ public void testWrite() throws Exception { new StreamCopier(status, status).transfer(new ByteArrayInputStream(content), out); assertEquals(content.length, out.getStatus().getSize(), 0L); } + assertNotNull(test.attributes().getFileId()); assertNotNull(test.attributes().getVersionId()); assertTrue(new DefaultFindFeature(session).find(test)); assertTrue(new SDSFindFeature(session, nodeid).find(test)); From fd4cf730519e35569b9796c5693ac692b67e88f2 Mon Sep 17 00:00:00 2001 From: David Kocher Date: Thu, 28 Mar 2024 14:41:53 +0100 Subject: [PATCH 2/2] Add caching. --- .../core/sds/SDSBatchDeleteFeature.java | 2 +- .../ch/cyberduck/core/sds/SDSCopyFeature.java | 4 +-- .../core/sds/SDSDelegatingCopyFeature.java | 2 +- .../cyberduck/core/sds/SDSDeleteFeature.java | 2 +- .../core/sds/SDSDirectoryFeature.java | 4 +-- .../core/sds/SDSExceptionMappingService.java | 2 +- .../ch/cyberduck/core/sds/SDSListService.java | 2 +- .../ch/cyberduck/core/sds/SDSMoveFeature.java | 8 +++--- .../cyberduck/core/sds/SDSNodeIdProvider.java | 13 +++++++-- .../ch/cyberduck/core/sds/SDSReadFeature.java | 2 +- .../cyberduck/core/sds/SDSUploadService.java | 4 +-- .../sds/SDSAttributesFinderFeatureTest.java | 2 +- .../sds/SDSMultipartWriteFeatureTest.java | 2 +- .../core/sds/SDSNodeIdProviderTest.java | 28 +++++++++---------- .../core/sds/SDSReadFeatureTest.java | 2 +- 15 files changed, 44 insertions(+), 35 deletions(-) diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSBatchDeleteFeature.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSBatchDeleteFeature.java index 82096dc9cae..fac6863ba49 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSBatchDeleteFeature.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSBatchDeleteFeature.java @@ -61,7 +61,7 @@ public void delete(final Map files, final PasswordCallback set.put(file.getParent(), nodes); } callback.delete(file); - nodeid.cache(file, null); + nodeid.cache(file, null, null); } for(List nodes : regular.values()) { try { diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSCopyFeature.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSCopyFeature.java index 881c69fd105..3d7705ab726 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSCopyFeature.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSCopyFeature.java @@ -65,9 +65,9 @@ public Path copy(final Path source, final Path target, final TransferStatus stat Long.parseLong(nodeid.getVersionId(target.getParent())), StringUtils.EMPTY, null); listener.sent(status.getLength()); - nodeid.cache(target, null); + nodeid.cache(target, null, null); final PathAttributes attributes = new SDSAttributesFinderFeature(session, nodeid).find(target); - nodeid.cache(target, attributes.getVersionId()); + nodeid.cache(target, attributes.getVersionId(), attributes.getFileId()); return target.withAttributes(attributes); } catch(ApiException e) { diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDelegatingCopyFeature.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDelegatingCopyFeature.java index b3f7b7732f1..3d8de2afb83 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDelegatingCopyFeature.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDelegatingCopyFeature.java @@ -52,7 +52,7 @@ public Path copy(final Path source, final Path target, final TransferStatus stat status.setFilekey(SDSTripleCryptEncryptorFeature.generateFileKey()); } final Path result = copy.copy(source, target, status, callback, listener); - nodeid.cache(target, null); + nodeid.cache(target, null, null); return result.withAttributes(new SDSAttributesFinderFeature(session, nodeid).find(result)); } diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDeleteFeature.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDeleteFeature.java index c985e01def5..49bfc73b0f8 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDeleteFeature.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDeleteFeature.java @@ -65,7 +65,7 @@ else if(file.attributes().getVerdict() == PathAttributes.Verdict.malicious) { new NodesApi(session.getClient()).removeNode( Long.parseLong(nodeid.getVersionId(file)), StringUtils.EMPTY); } - nodeid.cache(file, null); + nodeid.cache(file, null, null); } catch(ApiException e) { throw new SDSExceptionMappingService(nodeid).map("Cannot delete {0}", e, file); diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDirectoryFeature.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDirectoryFeature.java index b3c77190c78..f5678ca0e2f 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDirectoryFeature.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSDirectoryFeature.java @@ -74,7 +74,7 @@ private Path createFolder(final Path folder) throws BackgroundException, ApiExce folderRequest.setParentId(Long.parseLong(nodeid.getVersionId(folder.getParent()))); folderRequest.setName(folder.getName()); final Node node = new NodesApi(session.getClient()).createFolder(folderRequest, StringUtils.EMPTY, null); - nodeid.cache(folder, String.valueOf(node.getId())); + nodeid.cache(folder, String.valueOf(node.getId()), String.valueOf(node.getReferenceId())); return folder.withAttributes(new SDSAttributesAdapter(session).toAttributes(node)); } @@ -89,7 +89,7 @@ protected Path createRoom(final Path room, final boolean encrypt) throws Backgro } roomRequest.setName(room.getName()); final Node node = new NodesApi(session.getClient()).createRoom(roomRequest, StringUtils.EMPTY, null); - nodeid.cache(room, String.valueOf(node.getId())); + nodeid.cache(room, String.valueOf(node.getId()), String.valueOf(node.getReferenceId())); if(encrypt) { final EncryptRoomRequest options = new EncryptRoomRequest(); options.setIsEncrypted(true); diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSExceptionMappingService.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSExceptionMappingService.java index bf5306e3e47..67f0472dc22 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSExceptionMappingService.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSExceptionMappingService.java @@ -71,7 +71,7 @@ public BackgroundException map(final String message, final ApiException failure, // "debugInfo":"File not found","errorCode":-40751 case -40751: // Invalidate cache on Node not found - fileid.cache(file, null); + fileid.cache(file, null, null); break; } break; diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSListService.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSListService.java index 90a1ec8f231..6f1662f07cf 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSListService.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSListService.java @@ -64,7 +64,7 @@ protected AttributedList list(final Path directory, final ListProgressList final PathAttributes attributes = feature.toAttributes(node); final EnumSet type = feature.toType(node); final Path file = new Path(directory, node.getName(), type, attributes); - nodeid.cache(file, String.valueOf(node.getId())); + nodeid.cache(file, String.valueOf(node.getId()), String.valueOf(node.getReferenceId())); children.add(file); } offset += chunksize; diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSMoveFeature.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSMoveFeature.java index 2cd09a50915..494c5b06d54 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSMoveFeature.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSMoveFeature.java @@ -68,8 +68,8 @@ public Path move(final Path file, final Path renamed, final TransferStatus statu if(containerService.isContainer(file)) { final Node node = new NodesApi(session.getClient()).updateRoom( new UpdateRoomRequest().name(renamed.getName()), nodeId, StringUtils.EMPTY, null); - nodeid.cache(renamed, file.attributes().getVersionId()); - nodeid.cache(file, null); + nodeid.cache(renamed, file.attributes().getVersionId(), file.attributes().getFileId()); + nodeid.cache(file, null, null); return renamed.withAttributes(new SDSAttributesAdapter(session).toAttributes(node)); } else { @@ -99,8 +99,8 @@ public Path move(final Path file, final Path renamed, final TransferStatus statu Long.parseLong(nodeid.getVersionId(renamed.getParent())), StringUtils.EMPTY, null); } - nodeid.cache(renamed, file.attributes().getVersionId()); - nodeid.cache(file, null); + nodeid.cache(renamed, file.attributes().getVersionId(), file.attributes().getFileId()); + nodeid.cache(file, null, null); // Copy original file attributes return renamed.withAttributes(new PathAttributes(file.attributes()).withVersionId(String.valueOf(nodeId))); } diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSNodeIdProvider.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSNodeIdProvider.java index 72a9c9a8615..2e065953dc2 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSNodeIdProvider.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSNodeIdProvider.java @@ -57,6 +57,11 @@ public SDSNodeIdProvider(final SDSSession session) { this.references = new CachingFileIdProvider(session.getCaseSensitivity()); } + public void cache(final Path file, final String nodeId, final String referenceId) { + this.versions.cache(file, nodeId); + this.references.cache(file, referenceId); + } + @Override public String getVersionId(final Path file) throws BackgroundException { if(StringUtils.isNotBlank(file.attributes().getVersionId())) { @@ -153,8 +158,12 @@ protected Node getNode(final Path file, final int chunksize) throws BackgroundEx if(log.isInfoEnabled()) { log.info(String.format("Return node %s for file %s", node.getId(), file)); } - versions.cache(file, node.getId().toString()); - references.cache(file, node.getReferenceId().toString()); + if(node.getId() != null) { + versions.cache(file, node.getId().toString()); + } + if(node.getReferenceId() != null) { + references.cache(file, node.getReferenceId().toString()); + } return node; } } diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSReadFeature.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSReadFeature.java index d10c7aa8f54..3d6a186e71e 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSReadFeature.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSReadFeature.java @@ -84,7 +84,7 @@ public InputStream read(final Path file, final TransferStatus status, final Conn case HttpStatus.SC_PARTIAL_CONTENT: return new HttpMethodReleaseInputStream(response, status); case HttpStatus.SC_NOT_FOUND: - nodeid.cache(file, null); + nodeid.cache(file, null, null); // Break through default: throw new DefaultHttpResponseExceptionMappingService().map("Download {0} failed", new HttpResponseException( diff --git a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSUploadService.java b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSUploadService.java index 758f666b06d..e2c2b532a08 100644 --- a/dracoon/src/main/java/ch/cyberduck/core/sds/SDSUploadService.java +++ b/dracoon/src/main/java/ch/cyberduck/core/sds/SDSUploadService.java @@ -171,7 +171,7 @@ public Node complete(final Path file, final String uploadToken, final TransferSt } } } - nodeid.cache(file, String.valueOf(upload.getId())); + nodeid.cache(file, String.valueOf(upload.getId()), String.valueOf(upload.getReferenceId())); return upload; } catch(ApiException e) { @@ -260,7 +260,7 @@ public void uncaughtException(final Thread t, final Throwable e) { break; case "done": // Set node id in transfer status - nodeid.cache(file, String.valueOf(uploadStatus.getNode().getId())); + nodeid.cache(file, String.valueOf(uploadStatus.getNode().getId()), String.valueOf(uploadStatus.getNode().getReferenceId())); // Mark parent status as complete status.withResponse(new SDSAttributesAdapter(session).toAttributes(uploadStatus.getNode())).setComplete(); signal.countDown(); diff --git a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSAttributesFinderFeatureTest.java b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSAttributesFinderFeatureTest.java index 291e9d33428..f0ab302f742 100644 --- a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSAttributesFinderFeatureTest.java +++ b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSAttributesFinderFeatureTest.java @@ -179,7 +179,7 @@ public void testChangedNodeId() throws Exception { // Assume previously seen but changed on server final String invalidId = String.valueOf(RandomUtils.nextLong()); test.attributes().setVersionId(invalidId); - nodeid.cache(test, invalidId); + nodeid.cache(test, invalidId, null); final SDSAttributesFinderFeature f = new SDSAttributesFinderFeature(session, nodeid); assertEquals(latestnodeid, f.find(test).getVersionId()); assertEquals(latestnodeid, test.attributes().getVersionId()); diff --git a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSMultipartWriteFeatureTest.java b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSMultipartWriteFeatureTest.java index fdb4df4317e..01bcea24556 100644 --- a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSMultipartWriteFeatureTest.java +++ b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSMultipartWriteFeatureTest.java @@ -179,7 +179,7 @@ public void testWriteParentRoomReplaced() throws Exception { final String rommname = new AlphanumericRandomStringService().random(); final Path room = new SDSDirectoryFeature(session, nodeid).mkdir( new Path(rommname, EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus()); - final String fileid = nodeid.getNodeId(room, 1); + final String fileid = String.valueOf(nodeid.getNode(room, 1).getId()); assertEquals(fileid, room.attributes().getVersionId()); final Path test = new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback()); diff --git a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSNodeIdProviderTest.java b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSNodeIdProviderTest.java index dc361ce41de..250dd7afd9d 100644 --- a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSNodeIdProviderTest.java +++ b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSNodeIdProviderTest.java @@ -50,20 +50,20 @@ public void getFileIdFile() throws Exception { final String name = String.format("%s%s", new AlphanumericRandomStringService().random(), new AlphanumericRandomStringService().random()); final Path file = new SDSTouchFeature(session, nodeid).touch(new Path(room, name, EnumSet.of(Path.Type.file)), new TransferStatus()); nodeid.clear(); - final String nodeId = nodeid.getNodeId(new Path(room, name, EnumSet.of(Path.Type.file)), 1); + final String nodeId = nodeid.getNode(new Path(room, name, EnumSet.of(Path.Type.file)), 1).getId().toString(); assertNotNull(nodeId); - assertEquals(nodeId, nodeid.getNodeId(new Path(room.withAttributes(PathAttributes.EMPTY), name, EnumSet.of(Path.Type.file)), 1)); - assertEquals(nodeId, nodeid.getNodeId(new Path(room, StringUtils.upperCase(name), EnumSet.of(Path.Type.file)), 1)); - assertEquals(nodeId, nodeid.getNodeId(new Path(room, StringUtils.lowerCase(name), EnumSet.of(Path.Type.file)), 1)); + assertEquals(nodeId, nodeid.getNode(new Path(room.withAttributes(PathAttributes.EMPTY), name, EnumSet.of(Path.Type.file)), 1).getId().toString()); + assertEquals(nodeId, nodeid.getNode(new Path(room, StringUtils.upperCase(name), EnumSet.of(Path.Type.file)), 1).getId().toString()); + assertEquals(nodeId, nodeid.getNode(new Path(room, StringUtils.lowerCase(name), EnumSet.of(Path.Type.file)), 1).getId().toString()); try { - assertNull(nodeid.getNodeId(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), 1)); + assertNull(nodeid.getNode(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), 1).getId().toString()); fail(); } catch(NotfoundException e) { // Expected } try { - assertNull(nodeid.getNodeId(new Path(room, name, EnumSet.of(Path.Type.directory)), 1)); + assertNull(nodeid.getNode(new Path(room, name, EnumSet.of(Path.Type.directory)), 1).getId().toString()); fail(); } catch(NotfoundException e) { @@ -80,7 +80,7 @@ public void getFileIdFileVersions() throws Exception { final Path file = new SDSTouchFeature(session, nodeid).touch(new Path(room, name, EnumSet.of(Path.Type.file)), new TransferStatus()); final String versionIdTouch = file.attributes().getVersionId(); nodeid.clear(); - assertEquals(versionIdTouch, nodeid.getNodeId(new Path(room, name, EnumSet.of(Path.Type.file)), 1)); + assertEquals(versionIdTouch, nodeid.getNode(new Path(room, name, EnumSet.of(Path.Type.file)), 1).getId().toString()); final byte[] content = RandomUtils.nextBytes(32769); final TransferStatus status = new TransferStatus(); status.setLength(content.length); @@ -92,7 +92,7 @@ public void getFileIdFileVersions() throws Exception { assertNotNull(file.attributes().getVersionId()); assertNotEquals(versionIdTouch, file.attributes().getVersionId()); nodeid.clear(); - assertEquals(file.attributes().getVersionId(), nodeid.getNodeId(new Path(room, name, EnumSet.of(Path.Type.file)), 1)); + assertEquals(file.attributes().getVersionId(), nodeid.getNode(new Path(room, name, EnumSet.of(Path.Type.file)), 1).getId().toString()); new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback()); } @@ -106,15 +106,15 @@ public void getFileIdDirectory() throws Exception { final Path file = new SDSTouchFeature(session, nodeid).touch(new Path(folder, name, EnumSet.of(Path.Type.file)), new TransferStatus()); assertNotNull(file.attributes().getVersionId()); nodeid.clear(); - assertEquals(folder.attributes().getVersionId(), nodeid.getNodeId(new Path(room, name, EnumSet.of(Path.Type.directory)), 1)); + assertEquals(folder.attributes().getVersionId(), nodeid.getNode(new Path(room, name, EnumSet.of(Path.Type.directory)), 1).getId().toString()); try { - assertNull(nodeid.getNodeId(new Path(room, name, EnumSet.of(Path.Type.file)), 1)); + assertNull(nodeid.getNode(new Path(room, name, EnumSet.of(Path.Type.file)), 1)); fail(); } catch(NotfoundException e) { // } - assertEquals(file.attributes().getVersionId(), nodeid.getNodeId(new Path(folder, file.getName(), EnumSet.of(Path.Type.file)), 1)); + assertEquals(file.attributes().getVersionId(), nodeid.getNode(new Path(folder, file.getName(), EnumSet.of(Path.Type.file)), 1).getId().toString()); new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback()); } @@ -128,10 +128,10 @@ public void getFileIdRoom() throws Exception { final Path subroom = new SDSDirectoryFeature(session, nodeid).mkdir(new Path(room, subroomname, EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus()); assertNotNull(subroom.attributes().getVersionId()); nodeid.clear(); - assertEquals(room.attributes().getVersionId(), nodeid.getNodeId(new Path(roomname, EnumSet.of(Path.Type.directory)), 1)); - assertEquals(subroom.attributes().getVersionId(), nodeid.getNodeId(new Path(room, subroomname, EnumSet.of(Path.Type.directory)), 1)); + assertEquals(room.attributes().getVersionId(), nodeid.getNode(new Path(roomname, EnumSet.of(Path.Type.directory)), 1).getId().toString()); + assertEquals(subroom.attributes().getVersionId(), nodeid.getNode(new Path(room, subroomname, EnumSet.of(Path.Type.directory)), 1).getId().toString()); try { - assertNull(nodeid.getNodeId(new Path(room, subroomname, EnumSet.of(Path.Type.file)), 1)); + assertNull(nodeid.getNode(new Path(room, subroomname, EnumSet.of(Path.Type.file)), 1)); fail(); } catch(NotfoundException e) { diff --git a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSReadFeatureTest.java b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSReadFeatureTest.java index 58f1b5ff59d..57126d45fbd 100644 --- a/dracoon/src/test/java/ch/cyberduck/core/sds/SDSReadFeatureTest.java +++ b/dracoon/src/test/java/ch/cyberduck/core/sds/SDSReadFeatureTest.java @@ -190,7 +190,7 @@ public void testChangedNodeId() throws Exception { // Assume previously seen but changed on server final String invalidId = String.valueOf(RandomUtils.nextLong()); test.attributes().setVersionId(invalidId); - nodeid.cache(test, invalidId); + nodeid.cache(test, invalidId, null); try { final InputStream in = new SDSReadFeature(session, nodeid).read(test, new TransferStatus().withRemote(test.attributes()), new DisabledLoginCallback()); fail();