complete commit()
authorKlaus Kaempf <kkaempf@suse.de>
Wed, 8 Feb 2006 13:25:52 +0000 (13:25 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Wed, 8 Feb 2006 13:25:52 +0000 (13:25 +0000)
zypp/target/TargetImpl.cc
zypp/target/TargetImpl.h

index cace53a..c512957 100644 (file)
@@ -125,11 +125,12 @@ namespace zypp
       commit (to_uninstall);
 
       if (medianr == 0) {                      // commit all
-       commit( to_install );
-       commit( to_srcinstall );
+       remaining_r = commit( to_install );
+       srcremaining_r = commit( to_srcinstall );
       }
       else {
        PoolItemList current_install;
+       PoolItemList current_srcinstall;
 
        for (PoolItemList::iterator it = to_install.begin(); it != to_install.end(); ++it) {
            Resolvable::constPtr res( it->resolvable() );
@@ -144,7 +145,10 @@ namespace zypp
                current_install.push_back( *it );
            }
        }
-       for (PoolItemList::iterator it = to_install.begin(); it != to_install.end(); ++it) {
+       PoolItemList bad = commit (current_install);
+       remaining_r.insert(remaining_r.end(), bad.begin(), bad.end());
+
+       for (PoolItemList::iterator it = to_srcinstall.begin(); it != to_srcinstall.end(); ++it) {
            Resolvable::constPtr res( it->resolvable() );
            Package::constPtr pkg( asKind<Package>(res) );
            if (pkg
@@ -154,18 +158,22 @@ namespace zypp
                srcremaining_r.push_back( *it );
            }
            else {
-               current_install.push_back( *it );
+               current_srcinstall.push_back( *it );
            }
        }
-       commit (current_install);
+       bad = commit (current_srcinstall);
+       srcremaining_r.insert(remaining_r.end(), bad.begin(), bad.end());
       }
 
       return;
     }
 
 
-    void TargetImpl::commit(const PoolItemList & items_r)
+    PoolItemList
+    TargetImpl::commit( const PoolItemList & items_r)
     {
+      PoolItemList remaining;
+
       MIL << "TargetImpl::commit(<list>)" << endl;
       for (PoolItemList::const_iterator it = items_r.begin();
        it != items_r.end(); it++)
@@ -182,6 +190,7 @@ namespace zypp
            RpmInstallPackageReceiver progress(it->resolvable());
            
            progress.connect();
+           bool success = true;
 
            try {
                progress.tryLevel( target::rpm::InstallResolvableReport::RPM );
@@ -208,12 +217,15 @@ namespace zypp
                            p->installOnly() ? rpm::RpmDb::RPMINST_NOUPGRADE : (rpm::RpmDb::RPMINST_NODEPS|rpm::RpmDb::RPMINST_FORCE));
                    }
                    catch (Exception & excpt_r) {
-                       progress.disconnect();
-                       ZYPP_RETHROW(excpt_r);
+                       remaining.push_back( *it );
+                       success = false;
+                       ZYPP_CAUGHT(excpt_r);
                    }
                }
            }
-             
+           if (success) {
+               it->status().setStatus( ResStatus::installed );
+           }
            progress.disconnect();
 
          }
@@ -232,14 +244,15 @@ namespace zypp
                rpm().removePackage(p, rpm::RpmDb::RPMINST_NODEPS);
            }
            progress.disconnect();
+           it->status().setStatus( ResStatus::uninstalled );
          }
 
-         it->status().setStatus( ResStatus::uninstalled );
-         MIL << "Successful remove, " << *it << " is now uninstalled " << endl;
        }
 #warning FIXME other resolvables
       }
 
+      return remaining;
+
     }
 
     rpm::RpmDb & TargetImpl::rpm()
index 187d861..119fea2 100644 (file)
@@ -74,8 +74,9 @@ namespace zypp
          media > 0 means limit commits to this media */
       void commit( ResPool pool_r, unsigned int medianr, PoolItemList & errors_r, PoolItemList & remaining_r, PoolItemList & srcremaining_r );
 
-      /** Commit ordered changes */
-      void commit( const PoolItemList & items_r );
+      /** Commit ordered changes
+         return uncommitted ones (due to error) */
+      PoolItemList commit( const PoolItemList & items_r );
 
       /** Overload to realize stream output. */
       virtual std::ostream & dumpOn( std::ostream & str ) const