Skip to content

Commit

Permalink
#1339 move uninstall to boardsmanager
Browse files Browse the repository at this point in the history
  • Loading branch information
jantje committed Nov 25, 2021
1 parent c5154a7 commit 658fbc3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
14 changes: 13 additions & 1 deletion io.sloeber.core/src/io/sloeber/core/api/BoardsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,19 @@ public static IStatus updatePlatforms(List<ArduinoPlatformVersion> platformsToIn
}

public static IStatus uninstall(ArduinoPlatformVersion curPlatform, IProgressMonitor monitor) {
return curPlatform.remove(monitor);
if (!curPlatform.isInstalled()) {
return Status.OK_STATUS;
}

File installFolder = curPlatform.getInstallPath().toFile();
try {
FileUtils.deleteDirectory(installFolder);
} catch (IOException e) {
return new Status(IStatus.ERROR, Activator.getId(), "Failed to remove folder" + installFolder.toString(), //$NON-NLS-1$
e);
}

return Status.OK_STATUS;
}

public static TreeMap<String, String> getAllmenus() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,16 @@
import static io.sloeber.core.Gson.GsonConverter.*;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;

import io.sloeber.core.Activator;
import io.sloeber.core.api.VersionNumber;
import io.sloeber.core.common.Const;

Expand Down Expand Up @@ -110,23 +104,6 @@ public List<IPath> getIncludePath() {
installPath.append(Const.VARIANTS_FOLDER_NAME + "/{build.variant}")); //$NON-NLS-1$
}

//TODO delete
public IStatus remove(IProgressMonitor monitor) {
// Check if we're installed
if (!isInstalled()) {
return Status.OK_STATUS;
}

try {
FileUtils.deleteDirectory(getInstallPath().toFile());
} catch (IOException e) {
return new Status(IStatus.ERROR, Activator.getId(), "Failed to remove folder" + getInstallPath().toString(), //$NON-NLS-1$
e);
}

return Status.OK_STATUS;
}

@Override
public int hashCode() {
final int prime = 31;
Expand Down

0 comments on commit 658fbc3

Please sign in to comment.