forward-port fix for #191311 stalle tmpfile
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Thu, 13 Jul 2006 11:03:01 +0000 (11:03 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Thu, 13 Jul 2006 11:03:01 +0000 (11:03 +0000)
package/libzypp.changes
zypp/source/yum/YUMScriptImpl.cc
zypp/source/yum/YUMScriptImpl.h

index bfe0294..59992f1 100644 (file)
@@ -1,4 +1,10 @@
 -------------------------------------------------------------------
+Thu Jul 13 12:52:58 CEST 2006 - dmacvicar@suse.de
+
+- backport fix for stalle tmpfile (#191311)
+- rev 3788
+
+-------------------------------------------------------------------
 Wed Jun 28 13:22:22 CEST 2006 - mt@suse.de
 
 - deactivated media manager code that was disabling the
index 4308c16..873f0fb 100644 (file)
@@ -13,6 +13,7 @@
 #include "zypp/Arch.h"
 #include "zypp/Edition.h"
 #include "zypp/base/Gettext.h"
+#include "zypp/ZYppFactory.h"
 
 #include "zypp/source/yum/YUMSourceImpl.h"
 
@@ -64,11 +65,14 @@ namespace zypp
       Pathname YUMScriptImpl::do_script() const {
        if (_do_script != "")
        {
-         _tmp_file = filesystem::TmpFile();
-         Pathname pth = _tmp_file.path();
-         ofstream st(pth.asString().c_str());
-         st << _do_script << endl;
-         return pth;
+         if ( !_tmp_do_script )
+            _tmp_do_script.reset(new filesystem::TmpDir(getZYpp()->tmpPath()));
+
+          Pathname pth = _tmp_do_script->path();
+          // FIXME check success
+          ofstream st(pth.asString().c_str());
+          st << _do_script << endl;
+          return pth;
        }
        else if (_do_location != "" && _do_location != "/")
        {
@@ -85,14 +89,18 @@ namespace zypp
        }
       }
       /** Get the script to undo the change */
-     Pathname YUMScriptImpl::undo_script() const {
+     Pathname YUMScriptImpl::undo_script() const
+     {
        if (_undo_script != "")
        {
-         _tmp_file = filesystem::TmpFile();
-         Pathname pth = _tmp_file.path();
-         ofstream st(pth.asString().c_str());
-         st << _undo_script << endl;
-         return pth;
+          if ( !_tmp_undo_script )
+            _tmp_undo_script.reset(new filesystem::TmpDir(getZYpp()->tmpPath()));
+
+          Pathname pth = _tmp_undo_script->path();
+          // FIXME check success
+          ofstream st(pth.asString().c_str());
+          st << _undo_script << endl;
+          return pth;
        }
        else if (_undo_location != "" && _undo_location != "/")
        {
index ea6fd59..ef8281a 100644 (file)
@@ -60,7 +60,9 @@ namespace zypp
        unsigned _do_media;
        /** Media number of the undo script */
        unsigned _undo_media;
-       mutable filesystem::TmpFile _tmp_file;
+
+        mutable shared_ptr<filesystem::TmpDir> _tmp_do_script;
+        mutable shared_ptr<filesystem::TmpDir> _tmp_undo_script;
 
        CheckSum _do_checksum;
        CheckSum _undo_checksum;