Index: main/trunk/gli/src/org/greenstone/gatherer/DebugStream.java
===================================================================
--- main/trunk/gli/src/org/greenstone/gatherer/DebugStream.java	(revision 34260)
+++ main/trunk/gli/src/org/greenstone/gatherer/DebugStream.java	(revision 34261)
@@ -57,4 +57,13 @@
     }
 
+
+    static public void setDebugging(boolean isEnabled, String caller) {
+	if(isEnabled) {
+	    System.err.println("**** START DEBUGGING (enabled by: " + caller + ")");
+	} else {
+	    System.err.println("**** END DEBUGGING (called by: " + caller + ")");
+	}
+	debugging_enabled = isEnabled;
+    }
 
     static synchronized public boolean isDebuggingEnabled()
Index: main/trunk/gli/src/org/greenstone/gatherer/file/FileManager.java
===================================================================
--- main/trunk/gli/src/org/greenstone/gatherer/file/FileManager.java	(revision 34260)
+++ main/trunk/gli/src/org/greenstone/gatherer/file/FileManager.java	(revision 34261)
@@ -53,4 +53,5 @@
 import org.greenstone.gatherer.util.DragComponent;
 import org.greenstone.gatherer.util.Utility;
+import org.greenstone.gatherer.DebugStream;
 
 /** Manages the moving of files within a separate thread.
@@ -546,8 +547,27 @@
 	    WorkspaceTreeNode source_node = new WorkspaceTreeNode(new_file);
 
+	    //DebugStream.setDebugging(true, "FileManager.ReplaceTask");
+
+	    // Some different handling if the old and new tail file names are the same and target file goes into the same
+	    // location in collection tree as source.
+	    // This avoids past errors upon replacing with same filename (diff file contents) where the attached meta gets lost,
+	    // or remote file gets updated but file gone missing in client-GLI view until collection reopened.
+	    boolean isSameLeafName = false;
+	    if(collection_tree_node.getFile().getName().equals(new_file.getName())) {
+		DebugStream.println(" @@@ File Replace: New file has the same name as existing.");
+		isSameLeafName = true;
+	    }
+	    
 	    File target_directory = collection_tree_node.getFile().getParentFile();
 	    CollectionTreeNode new_collection_tree_node = new CollectionTreeNode(new File(target_directory, new_file.getName()));
-	    // copy the new file in - but don't bring metadata
-	    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);
+	    
+	    FileNode parent = (FileNode)collection_tree_node.getParent(); // store the original source's parent, need it several times after changing source
+	   
+	    if(!isSameLeafName) {
+		// If the file name of the replacing file is NOT the same as the one being replaced
+		// copy the new file in - but don't bring metadata
+		file_queue.addJob(System.currentTimeMillis(), Gatherer.g_man.gather_pane.workspace_tree, new FileNode[] { source_node }, collection_tree, parent, FileJob.COPY_FILE_ONLY);
+	    }
+	    
 	    if (Gatherer.isGsdlRemote) {
 		String collection_name = CollectionManager.getLoadedCollectionName();
@@ -555,6 +575,17 @@
 		Gatherer.remoteGreenstoneServer.uploadFilesIntoCollection(collection_name, new File[] { new_file }, target_directory);
 	    }
-	    // do a replace of old file with new file
-	    file_queue.addJob(System.currentTimeMillis(), collection_tree, new FileNode[] { collection_tree_node }, collection_tree, new_collection_tree_node, FileJob.REPLACE);
+
+	    if(isSameLeafName) {
+		// If the file name of the replacing file IS the same as the one being replaced
+		// 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
+		file_queue.addJob(System.currentTimeMillis(), Gatherer.g_man.gather_pane.workspace_tree, new FileNode[] { source_node }, collection_tree, parent, FileJob.COPY);
+	    } else {
+		// If the file name of the replacing file is NOT the same as the one being replaced, final step to finish off:
+		// do a replace of old file with new file
+		file_queue.addJob(System.currentTimeMillis(), collection_tree, new FileNode[] { collection_tree_node }, collection_tree, new_collection_tree_node, FileJob.REPLACE);
+	    }
+
+	    //DebugStream.setDebugging(false, "FileManager.ReplaceTask");
+
 	}
     }
