This is an automated email from the ASF dual-hosted git repository.

dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-mft.git

commit b1d0143472a5abb218ed28d21ead34d3bbf3ad03
Author: Dimuthu Wannipurage <[email protected]>
AuthorDate: Tue Feb 7 13:18:26 2023 -0500

    Avoiding copying files which were already copied
---
 .../airavata/mft/agent/TransferOrchestrator.java    | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git 
a/agent/service/src/main/java/org/apache/airavata/mft/agent/TransferOrchestrator.java
 
b/agent/service/src/main/java/org/apache/airavata/mft/agent/TransferOrchestrator.java
index 8b4fc3e..5395876 100644
--- 
a/agent/service/src/main/java/org/apache/airavata/mft/agent/TransferOrchestrator.java
+++ 
b/agent/service/src/main/java/org/apache/airavata/mft/agent/TransferOrchestrator.java
@@ -119,6 +119,27 @@ public class TransferOrchestrator {
                 throw new Exception("Expected a file as the source but 
received " + srcMetadata.getMetadataCase().name());
             }
 
+            Optional<MetadataCollector> dstMetadataCollectorOp = 
MetadataCollectorResolver
+                    
.resolveMetadataCollector(destStorage.getStorageCase().name());
+
+            MetadataCollector dstMetadataCollector = 
dstMetadataCollectorOp.orElseThrow(() -> new Exception("Could not find a 
metadata collector for destination"));
+            dstMetadataCollector.init(destStorage, destSecret);
+
+            if 
(dstMetadataCollector.isAvailable(endpointPath.getDestinationPath())) {
+                ResourceMetadata destinationMetadata = 
dstMetadataCollector.getResourceMetadata(endpointPath.getDestinationPath(), 
false);
+                if (destinationMetadata.getMetadataCase() == 
ResourceMetadata.MetadataCase.FILE &&
+                        destinationMetadata.getFile().getResourceSize() == 
srcMetadata.getFile().getResourceSize()) {
+                    logger.info("Ignoring the transfer of file {} as it is 
available in the destination", endpointPath.getSourcePath());
+                    updateStatus.accept(endpointPath, new TransferState()
+                            .setPercentage(100)
+                            .setState("COMPLETED")
+                            .setUpdateTimeMils(System.currentTimeMillis())
+                            .setDescription("Ignoring transfer as the file is 
available in destination"));
+
+                    return;
+                }
+            }
+
             ConnectorConfig srcCC = 
ConnectorConfig.ConnectorConfigBuilder.newBuilder()
                     .withTransferId(transferId)
                     .withSecret(sourceSecret)

Reply via email to