From dec3adcb739aaa56c963d850df82033eeaa156e6 Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Thu, 13 Jul 2006 11:03:01 +0000 Subject: [PATCH] forward-port fix for #191311 stalle tmpfile --- package/libzypp.changes | 6 ++++++ zypp/source/yum/YUMScriptImpl.cc | 30 +++++++++++++++++++----------- zypp/source/yum/YUMScriptImpl.h | 4 +++- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/package/libzypp.changes b/package/libzypp.changes index bfe0294..59992f1 100644 --- a/package/libzypp.changes +++ b/package/libzypp.changes @@ -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 diff --git a/zypp/source/yum/YUMScriptImpl.cc b/zypp/source/yum/YUMScriptImpl.cc index 4308c16..873f0fb 100644 --- a/zypp/source/yum/YUMScriptImpl.cc +++ b/zypp/source/yum/YUMScriptImpl.cc @@ -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 != "/") { diff --git a/zypp/source/yum/YUMScriptImpl.h b/zypp/source/yum/YUMScriptImpl.h index ea6fd59..ef8281a 100644 --- a/zypp/source/yum/YUMScriptImpl.h +++ b/zypp/source/yum/YUMScriptImpl.h @@ -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 _tmp_do_script; + mutable shared_ptr _tmp_undo_script; CheckSum _do_checksum; CheckSum _undo_checksum; -- 2.7.4