[Title] [INST] Remove extracted SDK image files.
authoryongsung1.kim <yongsung1.kim@samsung.com>
Thu, 10 Jan 2013 09:53:59 +0000 (18:53 +0900)
committeryongsung1.kim <yongsung1.kim@samsung.com>
Thu, 10 Jan 2013 09:53:59 +0000 (18:53 +0900)
[Desc.] InstallManager removes extracted SDK image files after it
completes installation or when it cancels extracting SDK image file.
[Issue] redmine 8030

Change-Id: Ic41cb68a8db004c9620ef2f13f4a9d3d60ba3801

InstallManager_java/src/org/tizen/installmanager/ui/dialog/ConfigurationDialog.java
InstallManager_java/src/org/tizen/installmanager/ui/page/InstallingPage.java
InstallManager_java/src/org/tizen/installmanager/ui/page/ViewController.java

index 8b75831..3aa5dde 100644 (file)
@@ -67,12 +67,13 @@ import org.tizen.installmanager.core.IMFatalException;
 import org.tizen.installmanager.core.SnapshotLog;
 import org.tizen.installmanager.lib.Log;
 import org.tizen.installmanager.lib.ErrorController.ErrorCode;
-import org.tizen.installmanager.lib.Platform;
 import org.tizen.installmanager.pkg.lib.PackageManager;
 import org.tizen.installmanager.pkg.model.Snapshot;
 import org.tizen.installmanager.pkg.model.SnapshotList;
+import org.tizen.installmanager.ui.InstallManagerWindow;
 import org.tizen.installmanager.ui.dialog.MessageBoxDlg.DialogType;
 import org.tizen.installmanager.ui.dialog.UnzipImageDialog.UNZIP_RESULT;
+import org.tizen.installmanager.ui.page.ViewController;
 import org.tizen.installmanager.util.PathUtil;
 
 
@@ -88,6 +89,7 @@ public class ConfigurationDialog extends Dialog {
        private String repository = "";
        private ServerType serverType = ServerType.SNAPSHOT;
        
+       private ViewController viewController;
        private SnapshotLogDialog snapshotDialog = null;
        private static final String STRING_TITLE = "Advanced Configuration";
 
@@ -124,6 +126,7 @@ public class ConfigurationDialog extends Dialog {
                super(parentShell);
                setShellStyle(SWT.BORDER | SWT.TITLE | SWT.APPLICATION_MODAL);
                controller = DistributionController.getInstance();
+               viewController = InstallManagerWindow.getInstallManagerWindow().getViewController();
        }
 
        /**
@@ -876,6 +879,7 @@ public class ConfigurationDialog extends Dialog {
                }
                
                if (unzipResult != UNZIP_RESULT.SUCCESS) {
+                       viewController.removeImageUnzipDir(); // If fail to extract image file, remove it.
                        repository = "";
                } else {
                        repository = sdkTempDir;
index 08c8c37..ec4b3b7 100644 (file)
@@ -319,6 +319,9 @@ public class InstallingPage extends PageTemplate {
                                @Override
                                public void run() {
                                        progressBar.setSelection(100);
+                                       
+                                       // Both network installing and image installing need remove temporary file.
+                                       viewController.removeImageUnzipDir(); 
 
                                        CompletePage completePage = mainWindow.getCompletePage();
                                        
index a34740a..1948b0a 100644 (file)
@@ -513,4 +513,33 @@ public class ViewController {
        public void loadSdkExtension() {
                sdkExtensionInfo.load();
        }
+       
+       /**
+        * Remove extracted SDK image file.
+        * @param unzipDir Extracting directory.
+        */
+       public void removeImageUnzipDir() {
+               String unzipDir = Config.INSTALL_MANAGER_TEMP_DIRECTORY;
+               File unzipBinaries = new File(PathUtil.get(unzipDir, "binary"));
+               File packageList = new File(PathUtil.get(unzipDir, PackageManager.getInstance().getPackageListFileName()));
+               
+               if (unzipBinaries.exists() && unzipBinaries.isDirectory()) {
+                       for (File binary : unzipBinaries.listFiles()) {
+                               binary.delete();
+                       }
+                       if (!unzipBinaries.delete()) {
+                               Log.err("Fail to remove SDK image package binaries. => " + unzipBinaries.getAbsolutePath());
+                       } else {
+                               Log.log("Success to remove SDK image package binaries. => " + unzipBinaries.getAbsolutePath());
+                       }
+               }
+               
+               if (packageList.exists()) {
+                       if (!packageList.delete()) {
+                               Log.err("Fail to remove SDK image package list. => " + packageList.getAbsolutePath());
+                       } else {
+                               Log.err("Success to remove SDK image package list. => " + packageList.getAbsolutePath());
+                       }
+               }
+       }
 }