- unbreak refresh
authorStanislav Visnovsky <visnov@suse.cz>
Fri, 15 Feb 2008 13:16:22 +0000 (13:16 +0000)
committerStanislav Visnovsky <visnov@suse.cz>
Fri, 15 Feb 2008 13:16:22 +0000 (13:16 +0000)
- provide API for cleaning up packages

zypp/RepoManager.cc
zypp/RepoManager.h

index fb12f0a..68dd4ac 100644 (file)
@@ -614,15 +614,10 @@ namespace zypp
         // ok we have the metadata, now exchange
         // the contents
        
-       // first, clean up the old rawcache metadata
-       // #FIXME       
-       // now, move the new metadata in
-       // #FIXME
-       
-        //TmpDir oldmetadata( TmpDir::makeSibling( rawpath ) );
-        //filesystem::rename( rawpath, oldmetadata.path() );
-        // move the just downloaded there
-        //filesystem::rename( tmpdir.path(), rawpath );
+        TmpDir oldmetadata( TmpDir::makeSibling( rawpath ) );
+        filesystem::rename( rawpath, oldmetadata.path() );
+         move the just downloaded there
+        filesystem::rename( tmpdir.path(), rawpath );
 
         // we are done.
         return;
@@ -655,6 +650,16 @@ namespace zypp
     progress.toMax();
   }
 
+  void RepoManager::cleanPackages( const RepoInfo &info,
+                                   const ProgressData::ReceiverFnc & progressfnc )
+  {
+    ProgressData progress(100);
+    progress.sendTo(progressfnc);
+
+    filesystem::recursive_rmdir(packagescache_path_for_repoinfo(_pimpl->options, info));
+    progress.toMax();
+  }
+
   void RepoManager::buildCache( const RepoInfo &info,
                                 CacheBuildPolicy policy,
                                 const ProgressData::ReceiverFnc & progressrcv )
index 711c3ff..5da29e7 100644 (file)
@@ -203,6 +203,17 @@ namespace zypp
                        const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
 
    /**
+    * \short Clean local package cache
+    *
+    * Empty local directory with downloaded packages
+    *
+    * \throws repo::RepoNoAliasException if can't figure an alias
+    * \throws Exception on unknown error.
+    */
+   void cleanPackages( const RepoInfo &info,
+                       const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+
+   /**
     * \short Status of metadata cache
     */
     RepoStatus cacheStatus( const RepoInfo &info ) const;