/**
* Deletes a file from both the workspace resource tree and the file system.
*/
protected void delete(UnifiedTreeNode node, boolean shouldKeepHistory) {
Resource target = (Resource) node.getResource();
try {
final boolean deleteLocalFile = !target.isLinked() && node.existsInFileSystem();
IFileStore localFile = deleteLocalFile ? node.getStore() : null;
if (deleteLocalFile && shouldKeepHistory)
recursiveKeepHistory(target.getLocalManager().getHistoryStore(), node);
node.removeChildrenFromTree();
//delete from disk
int work = ticks < 0 ? 0 : ticks;
ticks -= work;
if (deleteLocalFile)
localFile.delete(EFS.NONE, Policy.subMonitorFor(monitor, work));
else
monitor.worked(work);
//delete from tree
if (node.existsInWorkspace())
target.deleteResource(true, status);
} catch (CoreException e) {
status.add(e.getStatus());
// delete might have been partly successful, so refresh to ensure in sync
try {
target.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e1) {
//ignore secondary failure - we are just trying to cleanup from first failure
}
}
}