Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHE-3973: Fix deletion of WS folder on WS deletion #4122

Merged
merged 5 commits into from
Feb 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@

import org.eclipse.che.api.core.model.workspace.Workspace;
import org.eclipse.che.api.workspace.server.WorkspaceFilesCleaner;
import org.eclipse.che.commons.lang.IoUtil;
import org.eclipse.che.plugin.docker.machine.local.node.provider.LocalWorkspaceFolderPathProvider;

import java.io.File;
import java.io.IOException;

import static java.lang.System.getenv;
import static org.eclipse.che.commons.lang.IoUtil.deleteRecursive;

/**
* Local implementation of the {@link WorkspaceFilesCleaner}.
*
* @author Alexander Andrienko
* @author Igor Vinokur
*/
@Singleton
public class LocalWorkspaceFilesCleaner implements WorkspaceFilesCleaner {
Expand All @@ -44,9 +47,9 @@ public LocalWorkspaceFilesCleaner(LocalWorkspaceFolderPathProvider workspaceFold
@Override
public void clear(Workspace workspace) throws IOException {
String workspacePath = workspaceFolderPathProvider.getPathByName(workspace.getConfig().getName());
File workspaceStorage = new File(workspacePath);
if (!workspacePath.equals(hostProjectsFolder) && workspaceStorage.exists()) {
IoUtil.deleteRecursive(workspaceStorage);
if (!workspacePath.equals(hostProjectsFolder)) {
// Remove the workspace folder located in the Che instance docker container.
deleteRecursive(new File(workspacePath.replace(getenv("CHE_INSTANCE"), "")));
}
}
}