@@ -707,6 +707,51 @@ public void backend_removeFile(String oid, String filepath) {
707707
708708 // Folder Pathing support
709709 //--------------------------------------------------------------------------
710+ /**
711+ * [Internal use, to be extended in future implementation]
712+ *
713+ * Copy a given file within the system
714+ *
715+ * WARNING: Copy operations are typically not "atomic" in nature, and can be unsafe where
716+ * missing files / corrupted data can occur when executed concurrently with other operations.
717+ *
718+ * In general "S3-like" object storage will not safely support atomic Copy operations.
719+ * Please use the `atomicCopySupported()` function to validate if such operations are supported.
720+ *
721+ * Note that both source, and destionation folder will be normalized to include the "/" path.
722+ * This operation may in effect function as a rename
723+ * If the destionation folder exists with content, the result will be merged. With the sourceFolder files, overwriting on conflicts.
724+ *
725+ * @param ObjectID of workspace
726+ * @param sourceFolder
727+ * @param destinationFolder
728+ *
729+ */
730+ public void backend_copyFolderPath (final String oid , final String sourceFolder ,
731+ final String destinationFolder ) {
732+
733+ // Get the list of valid sub paths in the sourceFolder
734+ Set <String > subPath = backend_getFileAndFolderPathSet (oid , sourceFolder , -1 , -1 );
735+
736+ //Special handling for the edge case where you try to move an empty folder and it just get removed instead
737+ if (subPath .isEmpty () && sourceFolder != null && sourceFolder !="" && sourceFolder != "/" && sourceFolder .length () > 0 ){
738+ subPath .add ("/" );
739+ }
740+
741+
742+ // Lets sync up all the folders first
743+ for (String dir : subPath ) {
744+ if (dir .endsWith ("/" )) {
745+ backend_ensureFolderPath (oid , destinationFolder + dir );
746+ }
747+ }
748+ // Lets sync up all the files next
749+ for (String file : subPath ) {
750+ if (file .endsWith ("/" ) == false ) {
751+ backend_copyFile (oid , sourceFolder + file , destinationFolder + file );
752+ }
753+ }
754+ }
710755
711756 /**
712757 * [Internal use, to be extended in future implementation]
@@ -724,6 +769,7 @@ public void backend_removeFolderPath(final String oid, final String folderPath)
724769 backend_setupWorkspace (oid );
725770 // Ensure any parend dir anchor exists if needed
726771 ensureParentPath (oid , folderPath );
772+
727773 // Remove the respective file
728774 removeFilePathRecursively (oid , folderPath );
729775 }
@@ -837,7 +883,6 @@ public long backend_modifiedTimestamp(final String oid, final String filepath) {
837883 @ Override
838884 public Set <String > backend_getFileAndFolderPathSet (final String oid , String folderPath ,
839885 final int minDepth , final int maxDepth ) {
840-
841886 // Lets build the query for the "root file"
842887 Bson query = null ;
843888
0 commit comments