From 3918ffce371097b418a5b892f973c6518885e656 Mon Sep 17 00:00:00 2001 From: donghee yang Date: Tue, 16 Apr 2013 18:22:34 +0900 Subject: [PATCH] [Title] Fixed a bug that temporary files remain undeleted --- src/pkg_server/client.rb | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/pkg_server/client.rb b/src/pkg_server/client.rb index e0593c8..351ac44 100644 --- a/src/pkg_server/client.rb +++ b/src/pkg_server/client.rb @@ -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 -- 2.34.1