[Zodb-checkins] SVN: ZODB/trunk/src/ repozo: Remove '.index' + files corresponding to backups being removed.

Tres Seaver tseaver at palladion.com
Fri Sep 17 09:25:16 EDT 2010


Log message for revision 116528:
  repozo:  Remove '.index' +  files corresponding to backups being removed.
  

Changed:
  U   ZODB/trunk/src/CHANGES.txt
  U   ZODB/trunk/src/ZODB/scripts/repozo.py
  U   ZODB/trunk/src/ZODB/scripts/tests/test_repozo.py

-=-
Modified: ZODB/trunk/src/CHANGES.txt
===================================================================
--- ZODB/trunk/src/CHANGES.txt	2010-09-17 13:24:01 UTC (rev 116527)
+++ ZODB/trunk/src/CHANGES.txt	2010-09-17 13:25:16 UTC (rev 116528)
@@ -8,6 +8,9 @@
 Bugs fixed
 ----------
 
+- Updated the 'repozo --kill-old-on-full' option to remove any '.index'
+  files corresponding to backups being removed.
+
 - When objects were added in savepoints and either the savepoint was
   rolled back (https://bugs.launchpad.net/zodb/+bug/143560) or the
   transaction was aborted
@@ -204,7 +207,7 @@
   iterator implementations should just raise StopIteration, which
   means they can now be implemented as generators.
 
-- The file-storage backup script, repoze, will now create a backup
+- The file-storage backup script, repozo, will now create a backup
   index file if an output file name is given via the --output/-o
   option.
 
@@ -225,9 +228,10 @@
 New Features
 ------------
 
-- Added a '--kill-old-on-full' argument to the backup options:  if passed,
-  remove any older full or incremental backup files from the repository after
-  doing a full backup. (https://bugs.launchpad.net/zope2/+bug/143158)
+- Added a '--kill-old-on-full' argument to the repozo backup options:
+  if passed, remove any older full or incremental backup files from the
+  repository after doing a full backup.
+  (https://bugs.launchpad.net/zope2/+bug/143158)
 
 - When transactions are aborted, new object ids allocated during the
   transaction are saved and used in subsequent transactions. This can

Modified: ZODB/trunk/src/ZODB/scripts/repozo.py
===================================================================
--- ZODB/trunk/src/ZODB/scripts/repozo.py	2010-09-17 13:24:01 UTC (rev 116527)
+++ ZODB/trunk/src/ZODB/scripts/repozo.py	2010-09-17 13:25:16 UTC (rev 116528)
@@ -410,14 +410,21 @@
     dat = root + '.dat'
     if dat in deletable:
         deletable.remove(dat)
+    index = root + '.index'
+    if index in deletable:
+        deletable.remove(index)
 
     for fname in deletable:
-        log('removing old backup file %s (and .dat)', fname)
+        log('removing old backup file %s (and .dat / .index)', fname)
         root, ext = os.path.splitext(fname)
         try:
             os.unlink(os.path.join(options.repository, root + '.dat'))
         except OSError:
             pass
+        try:
+            os.unlink(os.path.join(options.repository, root + '.index'))
+        except OSError:
+            pass
         os.unlink(os.path.join(options.repository, fname))
 
 def do_full_backup(options):

Modified: ZODB/trunk/src/ZODB/scripts/tests/test_repozo.py
===================================================================
--- ZODB/trunk/src/ZODB/scripts/tests/test_repozo.py	2010-09-17 13:24:01 UTC (rev 116527)
+++ ZODB/trunk/src/ZODB/scripts/tests/test_repozo.py	2010-09-17 13:25:16 UTC (rev 116528)
@@ -457,7 +457,10 @@
             self.failUnless(os.path.isfile(fqn))
 
     def test_doesnt_remove_current_repozo_files(self):
-        FILENAMES = ['2009-12-20-10-08-03.fs', '2009-12-20-10-08-03.dat']
+        FILENAMES = ['2009-12-20-10-08-03.fs',
+                     '2009-12-20-10-08-03.dat',
+                     '2009-12-20-10-08-03.index',
+                    ]
         self._callFUT(filenames=FILENAMES)
         remaining = os.listdir(self._repository_directory)
         self.assertEqual(len(remaining), len(FILENAMES))
@@ -466,9 +469,19 @@
             self.failUnless(os.path.isfile(fqn))
 
     def test_removes_older_repozo_files(self):
-        OLDER_FULL = ['2009-12-20-00-01-03.fs', '2009-12-20-00-01-03.dat']
-        DELTAS = ['2009-12-21-00-00-01.deltafs', '2009-12-22-00-00-01.deltafs']
-        CURRENT_FULL = ['2009-12-23-00-00-01.fs', '2009-12-23-00-00-01.dat']
+        OLDER_FULL = ['2009-12-20-00-01-03.fs',
+                      '2009-12-20-00-01-03.dat',
+                      '2009-12-20-00-01-03.index',
+                     ]
+        DELTAS = ['2009-12-21-00-00-01.deltafs',
+                  '2009-12-21-00-00-01.index',
+                  '2009-12-22-00-00-01.deltafs',
+                  '2009-12-22-00-00-01.index',
+                 ]
+        CURRENT_FULL = ['2009-12-23-00-00-01.fs',
+                        '2009-12-23-00-00-01.dat',
+                        '2009-12-23-00-00-01.index',
+                       ]
         FILENAMES = OLDER_FULL + DELTAS + CURRENT_FULL
         self._callFUT(filenames=FILENAMES)
         remaining = os.listdir(self._repository_directory)
@@ -484,10 +497,19 @@
             self.failUnless(os.path.isfile(fqn))
 
     def test_removes_older_repozo_files_zipped(self):
-        OLDER_FULL = ['2009-12-20-00-01-03.fsz', '2009-12-20-00-01-03.dat']
+        OLDER_FULL = ['2009-12-20-00-01-03.fsz',
+                      '2009-12-20-00-01-03.dat',
+                      '2009-12-20-00-01-03.index',
+                     ]
         DELTAS = ['2009-12-21-00-00-01.deltafsz',
-                  '2009-12-22-00-00-01.deltafsz']
-        CURRENT_FULL = ['2009-12-23-00-00-01.fsz', '2009-12-23-00-00-01.dat']
+                  '2009-12-21-00-00-01.index',
+                  '2009-12-22-00-00-01.deltafsz',
+                  '2009-12-22-00-00-01.index',
+                 ]
+        CURRENT_FULL = ['2009-12-23-00-00-01.fsz',
+                        '2009-12-23-00-00-01.dat',
+                        '2009-12-23-00-00-01.index',
+                       ]
         FILENAMES = OLDER_FULL + DELTAS + CURRENT_FULL
         self._callFUT(filenames=FILENAMES)
         remaining = os.listdir(self._repository_directory)



More information about the Zodb-checkins mailing list