mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-04 23:55:26 +02:00
Fix 162962 - "duplicate name collision" when copying directory by improving RemoteFileSubSystem.removeCachedRemoteFile() such that when a file is removed, all its children are also removed from the cache.
This commit is contained in:
parent
cbfe5a4281
commit
1a713cc7e9
2 changed files with 22 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. All rights reserved.
|
||||
* Copyright (c) 2006 IBM Corporation and others. All rights reserved.
|
||||
* This program and the accompanying materials are made available under the terms
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
|
@ -12,6 +12,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - Fix 158534 - NPE in upload/download after conflict
|
||||
* Martin Oberhuber (Wind River) - Fix 162962 - recursive removeCachedRemoteFile()
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.subsystems.files.core.servicesubsystem;
|
||||
|
@ -700,6 +701,8 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I
|
|||
parents[i] = folderOrFiles[i].getParentPath();
|
||||
names[i] = folderOrFiles[i].getName();
|
||||
folderOrFiles[i].markStale(true);
|
||||
//bug 162962: need to recursively remove children from cache
|
||||
removeCachedRemoteFile(folderOrFiles[i]);
|
||||
}
|
||||
IFileService service = getFileService();
|
||||
try
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 IBM Corporation. All rights reserved.
|
||||
* Copyright (c) 2002, 2006 IBM Corporation and others. All rights reserved.
|
||||
* This program and the accompanying materials are made available under the terms
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
|
@ -11,7 +11,7 @@
|
|||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
* Martin Oberhuber (Wind River) - Fix 162962 - recursive removeCachedRemoteFile()
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.subsystems.files.core.subsystems;
|
||||
|
@ -28,6 +28,7 @@ import java.net.UnknownHostException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
|
@ -1624,6 +1625,21 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi
|
|||
}
|
||||
}
|
||||
}
|
||||
//Workaround for bug 162962: getContents() incomplete, children not deleted
|
||||
//If getContents() is implemented correctly, no matches should be removed
|
||||
String prefix = file.getAbsolutePath() + file.getSeparator();
|
||||
//Clone the hashMap in order to avoid ConcurrentModificationException in the iterator
|
||||
HashMap tmpMap = (HashMap)_cachedRemoteFiles.clone();
|
||||
Iterator it = tmpMap.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String remotePath = (String)it.next();
|
||||
if (remotePath.startsWith(prefix)) {
|
||||
//FIXME this should never be called if getContents() is implemented correctly
|
||||
//such that children are already removed in the code above.
|
||||
removeCachedRemoteFile(remotePath);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
_cachedRemoteFiles.remove(file.getAbsolutePath());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue