Skip to content

Commit

Permalink
If delete fail, wait a little, refresh and retry
Browse files Browse the repository at this point in the history
Fix #275
  • Loading branch information
laeubi committed May 21, 2024
1 parent deb75d4 commit f8ff22b
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
Expand Down Expand Up @@ -134,11 +137,24 @@ private void removeAllWorkingSets() {
}

private void cleanupWorkspace() {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
try {
ResourcesPlugin.getWorkspace().getRoot().delete(true, null);
root.delete(true, null);
} catch (CoreException e) {
TestPlugin.getDefault().getLog().log(e.getStatus());
throw createAssertionError(e);
// give it some more time
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e1) {
}
try {
root.refreshLocal(IResource.DEPTH_INFINITE, null);
if (root.exists()) {
root.delete(true, null);
}
} catch (CoreException e1) {
TestPlugin.getDefault().getLog().log(e.getStatus());
throw createAssertionError(e);
}
} finally {
project1 = null;
project2 = null;
Expand Down

0 comments on commit f8ff22b

Please sign in to comment.