Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Silbe <sascha-pgp@silbe.org>2018-01-22 17:08:00 (GMT)
committer Sascha Silbe <sascha-pgp@silbe.org>2018-01-22 17:08:00 (GMT)
commit482bbca1532cb100c89a23fb28736857e3d83518 (patch)
treef50422417d81fb26ee43dec61b29a592aa31ce98
parentdc8b667fc3e6bf855762deb775c83ea12bd07a6b (diff)
fsemulation: use filesize property if setHEADmaster
Checking out each entry just for determining the file size is very expensive. Try looking up the filesize property first and use it if available. Compared to checking out the entry this is so much cheaper that the additional overhead in case the property isn't available (unlikely) doesn't really matter. And in the other case it's a huge speed-up.
-rw-r--r--fsemulation.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/fsemulation.py b/fsemulation.py
index 8e89fef..7f004a0 100644
--- a/fsemulation.py
+++ b/fsemulation.py
@@ -440,7 +440,9 @@ class DataStore(object):
@synchronised
def get_size(self, object_id):
- # FIXME: make use of filesize property if available
+ props = self.get_properties(object_id, ['filesize'])
+ if props.get('filesize'):
+ return int(props['filesize'])
path = self.get_data(object_id)
if not path:
return 0