- Timestamp:
- 2020-07-11T08:00:38+12:00 (4 years ago)
- Location:
- main/trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/DebugStream.java
r31692 r34261 57 57 } 58 58 59 60 static public void setDebugging(boolean isEnabled, String caller) { 61 if(isEnabled) { 62 System.err.println("**** START DEBUGGING (enabled by: " + caller + ")"); 63 } else { 64 System.err.println("**** END DEBUGGING (called by: " + caller + ")"); 65 } 66 debugging_enabled = isEnabled; 67 } 59 68 60 69 static synchronized public boolean isDebuggingEnabled() -
main/trunk/gli/src/org/greenstone/gatherer/file/FileManager.java
r22605 r34261 53 53 import org.greenstone.gatherer.util.DragComponent; 54 54 import org.greenstone.gatherer.util.Utility; 55 import org.greenstone.gatherer.DebugStream; 55 56 56 57 /** Manages the moving of files within a separate thread. … … 546 547 WorkspaceTreeNode source_node = new WorkspaceTreeNode(new_file); 547 548 549 //DebugStream.setDebugging(true, "FileManager.ReplaceTask"); 550 551 // Some different handling if the old and new tail file names are the same and target file goes into the same 552 // location in collection tree as source. 553 // This avoids past errors upon replacing with same filename (diff file contents) where the attached meta gets lost, 554 // or remote file gets updated but file gone missing in client-GLI view until collection reopened. 555 boolean isSameLeafName = false; 556 if(collection_tree_node.getFile().getName().equals(new_file.getName())) { 557 DebugStream.println(" @@@ File Replace: New file has the same name as existing."); 558 isSameLeafName = true; 559 } 560 548 561 File target_directory = collection_tree_node.getFile().getParentFile(); 549 562 CollectionTreeNode new_collection_tree_node = new CollectionTreeNode(new File(target_directory, new_file.getName())); 550 // copy the new file in - but don't bring metadata 551 file_queue.addJob(System.currentTimeMillis(), Gatherer.g_man.gather_pane.workspace_tree, new FileNode[] { source_node }, collection_tree, (FileNode)collection_tree_node.getParent(), FileJob.COPY_FILE_ONLY); 563 564 FileNode parent = (FileNode)collection_tree_node.getParent(); // store the original source's parent, need it several times after changing source 565 566 if(!isSameLeafName) { 567 // If the file name of the replacing file is NOT the same as the one being replaced 568 // copy the new file in - but don't bring metadata 569 file_queue.addJob(System.currentTimeMillis(), Gatherer.g_man.gather_pane.workspace_tree, new FileNode[] { source_node }, collection_tree, parent, FileJob.COPY_FILE_ONLY); 570 } 571 552 572 if (Gatherer.isGsdlRemote) { 553 573 String collection_name = CollectionManager.getLoadedCollectionName(); … … 555 575 Gatherer.remoteGreenstoneServer.uploadFilesIntoCollection(collection_name, new File[] { new_file }, target_directory); 556 576 } 557 // do a replace of old file with new file 558 file_queue.addJob(System.currentTimeMillis(), collection_tree, new FileNode[] { collection_tree_node }, collection_tree, new_collection_tree_node, FileJob.REPLACE); 577 578 if(isSameLeafName) { 579 // If the file name of the replacing file IS the same as the one being replaced 580 // perform a COPY operation, which will copy across metadata too, after confirming whether the user really wants to replace the source with identically named targed 581 file_queue.addJob(System.currentTimeMillis(), Gatherer.g_man.gather_pane.workspace_tree, new FileNode[] { source_node }, collection_tree, parent, FileJob.COPY); 582 } else { 583 // If the file name of the replacing file is NOT the same as the one being replaced, final step to finish off: 584 // do a replace of old file with new file 585 file_queue.addJob(System.currentTimeMillis(), collection_tree, new FileNode[] { collection_tree_node }, collection_tree, new_collection_tree_node, FileJob.REPLACE); 586 } 587 588 //DebugStream.setDebugging(false, "FileManager.ReplaceTask"); 589 559 590 } 560 591 }
Note:
See TracChangeset
for help on using the changeset viewer.