[Esbox-commits] r1878 - branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards
andregomes at garage.maemo.org
andregomes at garage.maemo.org
Fri Jul 17 22:07:24 EEST 2009
Author: andregomes
Date: 2009-07-17 22:07:23 +0300 (Fri, 17 Jul 2009)
New Revision: 1878
Modified:
branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/DownloadUtility.java
branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstaller.java
Log:
Removing Maemo SDK Image File after installation.
Modified: branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/DownloadUtility.java
===================================================================
--- branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/DownloadUtility.java 2009-07-16 23:19:00 UTC (rev 1877)
+++ branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/DownloadUtility.java 2009-07-17 19:07:23 UTC (rev 1878)
@@ -23,7 +23,9 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.maemo.esbox.internal.vm.vmware.Activator;
import org.maemo.mica.common.core.MicaException;
@@ -200,6 +202,22 @@
return (new Path(localPath.getFile())).append(fileName).toOSString();
}
+ /**
+ * Get path for the image file saved locally.
+ * @param downloadFile
+ * @return The path for the image file saved locally.
+ * @throws MicaException
+ */
+ public static IPath getFilePath(FileDownload downloadFile) throws MicaException {
+ CookieHandler.setDefault(new SessionHandler());
+ URL removeURL = getRemoteFileURL(downloadFile, new NullProgressMonitor());
+ URL localURL = downloadFile.getLocalURL();
+ if (removeURL == null || localURL == null)
+ throw new MicaException("Cannot recover file path.");
+
+ return new Path(getFileName(removeURL, localURL));
+ }
+
private static long getPreviousDownload(String localFileName) {
File previousFile = new File(localFileName);
if (previousFile.exists()) {
Modified: branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstaller.java
===================================================================
--- branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstaller.java 2009-07-16 23:19:00 UTC (rev 1877)
+++ branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstaller.java 2009-07-17 19:07:23 UTC (rev 1878)
@@ -24,8 +24,11 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.window.Window;
@@ -38,7 +41,10 @@
import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
import org.maemo.esbox.vm.ui.SelectVirtualMachineDialog;
import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
+import org.maemo.mica.common.core.EFSFileUtils;
+import org.maemo.mica.common.core.MicaException;
import org.maemo.mica.common.core.Policy;
+import org.maemo.mica.common.core.filesystem.IFileSystemAccess;
import org.maemo.mica.common.core.machine.IBuildMachine;
import org.maemo.mica.common.core.machine.IMachine;
import org.maemo.mica.common.core.machine.MachineRegistry;
@@ -142,7 +148,7 @@
if (cannotProceed(status))
return status;
}
-
+ removeImageFiles();
return Activator.createStatus(IStatus.OK, "Maemo SDK Virtual Image was properly installed.");
}
@@ -150,7 +156,25 @@
return status.matches(IStatus.CANCEL) || status.matches(IStatus.ERROR);
}
+
/**
+ * Remove downloaded Maemo SDK virtual image file.
+ */
+ public void removeImageFiles() {
+ reporter.logInfo("Removing Maemo SDK virtual image files...");
+ FileDownload downloadFile = installData.getFileToDownload();
+ IPath path;
+ try {
+ path = DownloadUtility.getFilePath(downloadFile);
+ } catch (MicaException e) {
+ reporter.logInfo("Maemo SDK virtual image files were not sucessfuly removed.");
+ return;
+ }
+ IFileSystemAccess fileSystemAccess = MachineRegistry.getInstance().getLocalMachine().getFileSystemAccess();
+ EFSFileUtils.deleteQuietly(path, fileSystemAccess, new NullProgressMonitor());
+ }
+
+ /**
* Download Maemo SDK virtual image. If the virtual image consists of more
* than one file, the other will be also downloaded.
*
More information about the Esbox-commits
mailing list