chiark / gitweb /
Fix recalculation of per-device backup counts.
authorRichard Kettlewell <rjk@greenend.org.uk>
Sat, 17 Aug 2013 17:08:34 +0000 (18:08 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sat, 17 Aug 2013 17:24:31 +0000 (18:24 +0100)
fixes #4

doc/CHANGES.html
src/Volume.cc

index 0977865..47eb873 100644 (file)
       <li><code>--retire</code> no longer fails if a host directory
       has already been removed.</li>
 
+      <li>Fixed recalculation of per-device backup counts, visible as
+      self-inconsistent reports when generated in the same invocation
+      of <code>rsbackup</code> as some other operation.</li>
+
     </ul>
 
     <h2>Changes In rsbackup 0.4.1</h2>
index 6df8a44..2222ff6 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright © 2011, 2012 Richard Kettlewell.
+// Copyright © 2011-2013 Richard Kettlewell.
 //
 // This program is free software: you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -27,6 +27,12 @@ bool Volume::valid(const std::string &name) {
 
 void Volume::calculate() {
   completed = 0;
+  for(perdevice_type::iterator it = perDevice.begin();
+      it != perDevice.end();
+      ++it) {
+    Volume::PerDevice &pd = it->second;
+    pd.count = 0;
+  }
   for(std::set<Backup *>::const_iterator it = backups.begin();
       it != backups.end();
       ++it) {
@@ -49,6 +55,15 @@ void Volume::calculate() {
         pd.newest = s->date;
     }
   }
+  for(perdevice_type::iterator it = perDevice.begin();
+      it != perDevice.end();
+      ) {
+    perdevice_type::iterator jt = it;
+    ++it;
+    Volume::PerDevice &pd = jt->second;
+    if(!pd.count)
+      perDevice.erase(jt);
+  }
 }
 
 void Volume::addBackup(Backup *backup) {