From: Duncan Mac-Vicar P Date: Tue, 1 Aug 2006 11:19:30 +0000 (+0000) Subject: forward port #192535 X-Git-Tag: BASE-SuSE-SLE-10-SP2-Branch~525 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4ced7482f1e4e7b98d050d8757de7ad79c78ddd1;p=platform%2Fupstream%2Flibzypp.git forward port #192535 --- diff --git a/zypp/source/yum/YUMScriptImpl.cc b/zypp/source/yum/YUMScriptImpl.cc index 873f0fb..6adcf69 100644 --- a/zypp/source/yum/YUMScriptImpl.cc +++ b/zypp/source/yum/YUMScriptImpl.cc @@ -66,11 +66,17 @@ namespace zypp if (_do_script != "") { if ( !_tmp_do_script ) - _tmp_do_script.reset(new filesystem::TmpDir(getZYpp()->tmpPath())); + _tmp_do_script.reset(new filesystem::TmpFile(getZYpp()->tmpPath(), "zypp-yum-do-script-")); Pathname pth = _tmp_do_script->path(); // FIXME check success ofstream st(pth.asString().c_str()); + + if ( !st ) + { + ZYPP_THROW(Exception(N_("Can't write the patch script to a temporary file."))); + } + st << _do_script << endl; return pth; } @@ -94,11 +100,17 @@ namespace zypp if (_undo_script != "") { if ( !_tmp_undo_script ) - _tmp_undo_script.reset(new filesystem::TmpDir(getZYpp()->tmpPath())); + _tmp_undo_script.reset(new filesystem::TmpFile(getZYpp()->tmpPath(), "zypp-yum-undo-script-")); Pathname pth = _tmp_undo_script->path(); // FIXME check success ofstream st(pth.asString().c_str()); + + if ( !st ) + { + ZYPP_THROW(Exception(N_("Can't write the patch script to a temporary file."))); + } + st << _undo_script << endl; return pth; } diff --git a/zypp/source/yum/YUMScriptImpl.h b/zypp/source/yum/YUMScriptImpl.h index ef8281a..aa4e5fd 100644 --- a/zypp/source/yum/YUMScriptImpl.h +++ b/zypp/source/yum/YUMScriptImpl.h @@ -61,8 +61,8 @@ namespace zypp /** Media number of the undo script */ unsigned _undo_media; - mutable shared_ptr _tmp_do_script; - mutable shared_ptr _tmp_undo_script; + mutable shared_ptr _tmp_do_script; + mutable shared_ptr _tmp_undo_script; CheckSum _do_checksum; CheckSum _undo_checksum; diff --git a/zypp/target/store/XMLFilesBackend.cc b/zypp/target/store/XMLFilesBackend.cc index 58aa73d..d1ef012 100644 --- a/zypp/target/store/XMLFilesBackend.cc +++ b/zypp/target/store/XMLFilesBackend.cc @@ -908,11 +908,18 @@ XMLFilesBackend::createScript(const zypp::parser::xmlstore::XMLPatchScriptData & detail::ResImplTraits::Ptr impl(new XMLScriptImpl()); ofstream file; - file.open(impl->_do_script.path().asString().c_str()); + file.open(impl->_do_script->path().asString().c_str()); + + if ( ! file ) + ZYPP_THROW(Exception(N_("Can't write the patch script to a temporary file."))); + file << parsed.do_script;; file.close(); - file.open(impl->_undo_script.path().asString().c_str()); + file.open(impl->_undo_script->path().asString().c_str()); + if ( ! file ) + ZYPP_THROW(Exception(N_("Can't write the patch script to a temporary file."))); + file << parsed.undo_script;; file.close(); diff --git a/zypp/target/store/xml/XMLScriptImpl.cc b/zypp/target/store/xml/XMLScriptImpl.cc index 2c1dd98..9ed5b71 100644 --- a/zypp/target/store/xml/XMLScriptImpl.cc +++ b/zypp/target/store/xml/XMLScriptImpl.cc @@ -30,8 +30,8 @@ namespace zypp /** Default ctor */ XMLScriptImpl::XMLScriptImpl() { - _do_script = TmpFile( TmpPath::defaultLocation(), "zypp-xmlstore-do-script-"); - _undo_script = TmpFile( TmpPath::defaultLocation(), "zypp-xmlstore-undo-script-"); + _do_script.reset( new TmpFile( TmpPath::defaultLocation(), "zypp-xmlstore-do-script-") ); + _undo_script.reset( new TmpFile( TmpPath::defaultLocation(), "zypp-xmlstore-undo-script-")); } /** Dtor */ @@ -39,15 +39,15 @@ namespace zypp {} Pathname XMLScriptImpl::do_script() const { - return _do_script.path(); + return _do_script->path(); } Pathname XMLScriptImpl::undo_script() const { - return _undo_script.path(); + return _undo_script->path(); } bool XMLScriptImpl::undo_available() const { - return _undo_script != ""; + return *_undo_script != ""; } ///////////////////////////////////////////////////////////////// diff --git a/zypp/target/store/xml/XMLScriptImpl.h b/zypp/target/store/xml/XMLScriptImpl.h index f76ae04..fee943c 100644 --- a/zypp/target/store/xml/XMLScriptImpl.h +++ b/zypp/target/store/xml/XMLScriptImpl.h @@ -68,9 +68,9 @@ namespace zypp /** Check whether script to undo the change is available */ virtual bool undo_available() const; - TmpFile _do_script; - TmpFile _undo_script; - + mutable shared_ptr _do_script; + mutable shared_ptr _undo_script; + TranslatedText _summary; TranslatedText _description;