[Title] Fixed a bug that temporary files remain undeleted
authordonghee yang <donghee.yang@samsung.com>
Tue, 16 Apr 2013 09:22:34 +0000 (18:22 +0900)
committerdonghee yang <donghee.yang@samsung.com>
Tue, 16 Apr 2013 09:22:34 +0000 (18:22 +0900)
src/pkg_server/client.rb

index e0593c8..351ac44 100644 (file)
@@ -1511,17 +1511,21 @@ class Client
 
                # install package
                #download
-               tmp_location = File.join(@tmp_path,Utils.create_uniq_name)
-               filepath = download(pkg_name, os, false, tmp_location)
-               if filepath.nil? or filepath[0].nil? then
-                       return false
-               end
+               tmp_location = nil
+               begin
+                       tmp_location = File.join(@tmp_path,Utils.create_uniq_name)
+                       filepath = download(pkg_name, os, false, tmp_location)
+                       if filepath.nil? or filepath[0].nil? then
+                               return false
+                       end
 
-               #install
-               ret = FileInstaller.install(pkg_name, filepath[0], type, @location, @log)
+                       #install
+                       ret = FileInstaller.install(pkg_name, filepath[0], type, @location, @log)
+               ensure
+                       #remove garbage
+                       FileUtils.rm_rf tmp_location if not tmp_location.nil? and File.exist? tmp_location
+               end
 
-               #remove garbage
-               FileUtils.rm_rf tmp_location
                return ret
        end