[jhbuild/desrt/master: 32/35] packagedb: write only one manifest
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jhbuild/desrt/master: 32/35] packagedb: write only one manifest
- Date: Sun, 4 Jan 2015 04:32:15 +0000 (UTC)
commit d589561ebf6ada1d246b2ac08d3d852f94425b51
Author: Ryan Lortie <desrt desrt ca>
Date: Sat Jan 3 22:34:04 2015 -0500
packagedb: write only one manifest
Because of the fact that the 'manifest' attribute on PackageEntry items
is a property and because of the fact that we check it each time we
convert a node to XML, we end up reading every manifest file every time
we go to update the packagedb (ie: every time we install a package).
Even worse: because self.manifest is now populated, we also write every
single manifest file each time we update the packagedb.
Avoid the problem by making the write explicit for the module being
added, and no other.
https://bugzilla.gnome.org/show_bug.cgi?id=742298
jhbuild/utils/packagedb.py | 22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/jhbuild/utils/packagedb.py b/jhbuild/utils/packagedb.py
index 9f18425..5b8acd6 100644
--- a/jhbuild/utils/packagedb.py
+++ b/jhbuild/utils/packagedb.py
@@ -93,6 +93,16 @@ class PackageEntry:
return dbentry
+ def write(self):
+ fd = file(os.path.join(self.manifests_dir, self.package + '.tmp'), 'w')
+ fd.write('\n'.join(self.manifest) + '\n')
+ if hasattr(os, 'fdatasync'):
+ os.fdatasync(fd.fileno())
+ else:
+ os.fsync(fd.fileno())
+ fd.close()
+ fileutils.rename(os.path.join(self.manifests_dir, self.package + '.tmp'),
+ os.path.join(self.manifests_dir, self.package))
def to_xml(self, doc):
entry_node = ET.Element('entry', {'package': self.package,
@@ -102,16 +112,7 @@ class PackageEntry:
if 'configure-hash' in self.metadata:
entry_node.attrib['configure-hash'] = \
self.metadata['configure-hash']
- if self.manifest is not None:
- fd = file(os.path.join(self.manifests_dir, self.package + '.tmp'), 'w')
- fd.write('\n'.join(self.manifest) + '\n')
- if hasattr(os, 'fdatasync'):
- os.fdatasync(fd.fileno())
- else:
- os.fsync(fd.fileno())
- fd.close()
- fileutils.rename(os.path.join(self.manifests_dir, self.package + '.tmp'),
- os.path.join(self.manifests_dir, self.package))
+
return entry_node
class PackageDB:
@@ -224,6 +225,7 @@ class PackageDB:
self._entries[package] = PackageEntry(package, version, metadata,
self.manifests_dir)
self._entries[package].manifest = contents
+ self._entries[package].write()
self._write_cache()
def check(self, package, version=None):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]