[Dextrose] [PATCH 5/5][dextrose2][sugar] Updater check bundle integrity
Martin Abente
martin.abente.lahaye at gmail.com
Tue Apr 19 17:21:28 EDT 2011
Add integrity check for each bundle, and thus avoid adding
trash bundles to journal.
Fixes #2588.
---
extensions/cpsection/updater/model.py | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/extensions/cpsection/updater/model.py b/extensions/cpsection/updater/model.py
index 9f27924..d18f6d6 100755
--- a/extensions/cpsection/updater/model.py
+++ b/extensions/cpsection/updater/model.py
@@ -26,6 +26,7 @@ import logging
import tempfile
from urlparse import urlparse
import traceback
+from zipfile import ZipFile
import gobject
import gio
@@ -378,5 +379,22 @@ class _Downloader(gobject.GObject):
logging.debug('closing output stream')
self._output_stream.close()
+ self._check_integrity()
+ def _check_integrity(self):
+ bundle_path = self._output_file.get_path()
+
+ try:
+ bundle_file = ZipFile(bundle_path, 'r')
+ except:
+ passed = False
+ else:
+ passed = (bundle_file.testzip() is None)
+ bundle_file.close()
+
+ if passed:
self.emit('finish', True)
+ else:
+ logging.error('updater: %s bundle file is corrupt' % bundle_path)
+ self.emit('finish', False)
+
--
1.7.4.4
More information about the Dextrose
mailing list