SVN: ZODB/trunk/src/ repozo: Remove '.index' + files corresponding to backups being removed.

Tres Seaver <[email protected]>
Newsgroups gmane.comp.python.zope.zodb.cvs
Message-ID <20100917132516.E0039941C0__23037.1951162399$1284729925$gmane$org@cvs.zope.org>
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)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.