From: Josef Reidinger Date: Fri, 2 May 2008 14:31:18 +0000 (+0000) Subject: release file after copy to cache as soon as possible. (bnc #381311) X-Git-Tag: BASE-SuSE-Linux-11_0-Branch~128 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d8be784ac87b8972903d3c0426745e92e1f2900f;p=platform%2Fupstream%2Flibzypp.git release file after copy to cache as soon as possible. (bnc #381311) --- diff --git a/zypp/Fetcher.cc b/zypp/Fetcher.cc index 95c6ed6..5267b3c 100644 --- a/zypp/Fetcher.cc +++ b/zypp/Fetcher.cc @@ -208,7 +208,7 @@ namespace zypp ZYPP_THROW( Exception("Can't copy " + tmp_file.asString() + " to " + dest_dir.asString())); } - + media.releaseFile((*it_res)->location); //not needed anymore, only eat space } catch (Exception & excpt_r) { diff --git a/zypp/MediaSetAccess.cc b/zypp/MediaSetAccess.cc index 39a1095..3cd0745 100644 --- a/zypp/MediaSetAccess.cc +++ b/zypp/MediaSetAccess.cc @@ -79,6 +79,25 @@ IMPL_PTR_TYPE(MediaSetAccess); // report->finish( file_url, source::DownloadFileReport::NO_ERROR, "" ); // return file; + void MediaSetAccess::releaseFile( const OnMediaLocation & on_media_file ) + { + releaseFile( on_media_file.filename(), on_media_file.medianr() ); + } + + void MediaSetAccess::releaseFile( const Pathname & file, unsigned media_nr) + { + media::MediaManager media_mgr; + media::MediaAccessId media; + + media = getMediaAccessId( media_nr); + DBG << "Going to release file " << file + << " from media number " << media_nr << endl; + + if ( ! media_mgr.isAttached(media) ) + return; //disattached media is free + + media_mgr.releaseFile (media, file); + } Pathname MediaSetAccess::provideFile( const OnMediaLocation & on_media_file ) { diff --git a/zypp/MediaSetAccess.h b/zypp/MediaSetAccess.h index 89596a0..09ec05d 100644 --- a/zypp/MediaSetAccess.h +++ b/zypp/MediaSetAccess.h @@ -131,6 +131,24 @@ namespace zypp Pathname provideFile(const Pathname & file, unsigned media_nr = 1 ); /** + * Release file from media. + * This signal that file is not needed anymore. + * + * \param on_media_file location of the file on media + */ + void releaseFile( const OnMediaLocation & on_media_file ); + + + /** + * Release file from media. + * This signal that file is not needed anymore. + * + * \param file path to the file relative to media URL + * \param media_nr the media number in the media set + */ + void releaseFile(const Pathname & file, unsigned media_nr = 1 ); + + /** * Provides direcotry \a dir from media number \a media_nr. * * \param dir path to the directory relative to media URL