[Title] cli: fixed read/write handling for sign
authorJihoon Song <jihoon80.song@samsung.com>
Mon, 24 Jun 2013 09:56:27 +0000 (18:56 +0900)
committerJihoon Song <jihoon80.song@samsung.com>
Mon, 24 Jun 2013 09:56:27 +0000 (18:56 +0900)
[Desc.]
[Issue]

Change-Id: Ied857ca06ce09c17c1badd6de096dd299514cb65

org.tizen.cli/src/org/tizen/cli/exec/sign/Main.java

index 853cca2..9620647 100644 (file)
@@ -308,33 +308,35 @@ extends AbstractLauncher
                 }
             };
         }
+        
         InputStream in = getFileHandler().read( profilesFilePath );
+        String version = null;
         
         try {
-            String version = container.readProfileXML( in );
+            version = container.readProfileXML( in );
             if ( version == null ) {
                 getPrompter().error( "Cannot load profiles in " + profilesFilePath );
                 return false;
             }
-            
-            // if old version, rewrite to new version.
-            if ( StringUtil.isEmpty( version ) ) {
-                getPrompter().notify( "Old version profile detected. Converting this automatically." );
-                
-                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-                container.writeProfileXML( outStream );
-                InputStream inForOut = new ByteArrayInputStream( outStream.toByteArray() );
-                
-                try {
-                    getFileHandler().write( profilesFilePath, inForOut );
-                } finally {
-                    tryClose( inForOut );
-                }
-            }
         } finally {
             IOUtil.tryClose( in );
         }
         
+        // if old version, rewrite to new version.
+        if ( StringUtil.isEmpty( version ) ) {
+            getPrompter().notify( "Old version profile detected. Converting this automatically." );
+            
+            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+            container.writeProfileXML( outStream );
+            InputStream inForOut = new ByteArrayInputStream( outStream.toByteArray() );
+            
+            try {
+                getFileHandler().write( profilesFilePath, inForOut );
+            } finally {
+                tryClose( inForOut );
+            }
+        }
+        
         return true;
     }