Mercurial > mozilla > hg > dogfood
comparison dogdish/dispatcher.py @ 20:71c36a7842d1
Use mtime to determine most recent update; don't cache updates since timestamps can change.
author | Jonathan Griffin <jgriffin@mozilla.com> |
---|---|
date | Mon, 12 Nov 2012 23:27:09 +0000 |
parents | 608df6b3de80 |
children | ce97a26e4c03 |
comparison
equal
deleted
inserted
replaced
19:608df6b3de80 | 20:71c36a7842d1 |
---|---|
49 def __init__(self, directory, filename): | 49 def __init__(self, directory, filename): |
50 self.directory = directory | 50 self.directory = directory |
51 self.filename = filename | 51 self.filename = filename |
52 self.path = os.path.join(directory, filename) | 52 self.path = os.path.join(directory, filename) |
53 self.stamp = filename[len(self.prefix):-len(self.suffix)] | 53 self.stamp = filename[len(self.prefix):-len(self.suffix)] |
54 self.modifiedTime = os.path.getmtime(self.path) | |
54 self.size = os.path.getsize(self.path) | 55 self.size = os.path.getsize(self.path) |
55 | 56 |
56 # cached properties | 57 # cached properties |
57 self._application = None | 58 self._application = None |
58 self._hash = None | 59 self._hash = None |
205 # check for new updates | 206 # check for new updates |
206 contents = self.update_class.updates(self.directory) | 207 contents = self.update_class.updates(self.directory) |
207 new = contents.difference(self.updates.keys()) | 208 new = contents.difference(self.updates.keys()) |
208 if not new: | 209 if not new: |
209 # directory contents unchanged from cached values | 210 # directory contents unchanged from cached values |
210 return False | 211 # return False |
211 | 212 # XXX: we can't rely on caching this, since in the case of a bad update, |
212 for update in new: | 213 # an earlier update will be promoted via 'touch'. |
214 pass | |
215 | |
216 for update in contents: | |
213 self.updates[update] = self.update_class(self.directory, update) | 217 self.updates[update] = self.update_class(self.directory, update) |
214 if self.current_update: | 218 if self.current_update: |
215 if self.updates[update].stamp > self.current_update.stamp: | 219 if self.updates[update].modifiedTime > self.current_update.modifiedTime: |
216 self.current_update = self.updates[update] | 220 self.current_update = self.updates[update] |
217 else: | 221 else: |
218 self.current_update = self.updates[update] | 222 self.current_update = self.updates[update] |
219 | 223 |
220 # TODO: could remove old files from the cache if not found in contents | 224 # TODO: could remove old files from the cache if not found in contents |