[Title] added to check ".sdk_delta.info" file upload is success or not.
authorGun Kim <gune.kim@samsung.com>
Fri, 5 Apr 2013 08:38:59 +0000 (17:38 +0900)
committerGun Kim <gune.kim@samsung.com>
Wed, 10 Apr 2013 04:10:05 +0000 (13:10 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: Ie7af8ac58d3fe4bacdba30b401a947130df21ed7

org.tizen.common/src/org/tizen/common/rds/RdsDeltaDetector.java
org.tizen.common/src/org/tizen/common/rds/RdsDeployer.java

index caa3dd8..272afc1 100755 (executable)
@@ -51,6 +51,7 @@ import org.tizen.common.util.IOUtil;
 import org.tizen.common.util.log.Logger;
 import org.tizen.sdblib.IDevice;
 import org.tizen.sdblib.SyncService;
+import org.tizen.sdblib.SyncService.SyncResult;
 
 /**
  * Delta Detector for Rapid Development Support.
@@ -79,12 +80,13 @@ public class RdsDeltaDetector {
      * Reads the <code>STR_TREE_FILE</code>, and sets the <code>oldTree</code>.
      */
     public void readOldTree() {
-        downloadOldTree();
+        String strLocalFile = downloadOldTree();
+        if ( strLocalFile == null ) {
+            return;
+        }
         Workspace workspace = ((Workspace)project.getWorkspace());
         ElementTreeReader treeReader = new ElementTreeReader(workspace.getSaveManager());
         
-        String strLocalFile = project.getLocation().toString() + "/" + STR_TREE_FILE;
-        
         DataInputStream input = null;
         try {
             input = new DataInputStream(new SafeFileInputStream(strLocalFile, strLocalFile + ".temp", TREE_BUFFER_SIZE));
@@ -125,7 +127,10 @@ public class RdsDeltaDetector {
         String deltaFileOnRemote = remotePath + STR_TREE_DIRECTORY + STR_TREE_FILE;
         strLocalFile = project.getLocation().toString() + "/" + STR_TREE_FILE;
         try {
-            device.getSyncService().pullFile(deltaFileOnRemote, strLocalFile, true, SyncService.getNullProgressMonitor());
+            SyncResult result = device.getSyncService().pullFile(deltaFileOnRemote, strLocalFile, true, SyncService.getNullProgressMonitor());
+            if ( result.getCode() != SyncService.RESULT_OK ) {
+                throw new Exception(result.getMessage());
+            }
         } catch (Exception e) {
             return null;
         }
index 15a9c7b..65ecf1b 100644 (file)
@@ -228,11 +228,7 @@ public abstract class RdsDeployer implements Closeable{
         File file = deltaListFile.makeFile(strProjectPath);
         if ( file != null ) {
             try {
-                command = RdsDeployer.makeRdsLog(NLS.bind(RdsMessages.RDS_PUSH_LOG, file.getCanonicalPath(), strAppInstallPath + "/" + file.getName()));
-                SyncResult result = getSyncService().pushFile(file.getCanonicalPath(), strAppInstallPath + "/" + file.getName(), SyncService.getNullProgressMonitor());
-                if ( result.getCode() != SyncService.RESULT_OK ) {
-                    throw new IOException(command);
-                }
+                pushFile(file.getCanonicalPath(), strAppInstallPath + "/" + file.getName());
                 printInfo( command );
             } catch (Exception e) {
                 newCoreException(RdsDeployer.makeRdsLog(RdsMessages.RDS_PUSH_ERROR), e);
@@ -318,7 +314,7 @@ public abstract class RdsDeployer implements Closeable{
         String strRemotePath = appInstallPath + RdsDeltaDetector.STR_TREE_DIRECTORY + RdsDeltaDetector.STR_TREE_FILE;
         
         try {
-            getSyncService().pushFile(strDeltaInfoFile, strRemotePath, SyncService.getNullProgressMonitor());
+            pushFile(strDeltaInfoFile, strRemotePath);
         } catch (Exception e) {
             Logger.error(RdsDeployer.makeRdsLog(RdsMessages.RDS_RES_INFO_PUSH_ERROR), e);
         }
@@ -328,6 +324,13 @@ public abstract class RdsDeployer implements Closeable{
         return RdsMessages.RDS_MODE_PREFIX + " " + log;
     }
     
+    private void pushFile(String source, String dest) throws Exception {
+        SyncResult result = getSyncService().pushFile(source, dest, SyncService.getNullProgressMonitor());
+        if ( result.getCode() != SyncService.RESULT_OK ) {
+            throw new Exception(result.getMessage());
+        }
+    }
+    
     /**
      * Creates a new exception.
      *