release file after copy to cache as soon as possible. (bnc #381311)
authorJosef Reidinger <jreidinger@suse.cz>
Fri, 2 May 2008 14:31:18 +0000 (14:31 +0000)
committerJosef Reidinger <jreidinger@suse.cz>
Fri, 2 May 2008 14:31:18 +0000 (14:31 +0000)
zypp/Fetcher.cc
zypp/MediaSetAccess.cc
zypp/MediaSetAccess.h

index 95c6ed6..5267b3c 100644 (file)
@@ -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)
         {
index 39a1095..3cd0745 100644 (file)
@@ -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 )
   {
index 89596a0..09ec05d 100644 (file)
@@ -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