diff --git a/remotefilelog/basepack.py b/remotefilelog/basepack.py --- a/remotefilelog/basepack.py +++ b/remotefilelog/basepack.py @@ -55,10 +55,11 @@ # lastrefesh is 0 so we'll immediately check for new packs on the first # failure. self.lastrefresh = 0 - - for filepath in self._getavailablepackfiles(): + totalsize = 0 + for filepath, size in self._getavailablepackfiles(): try: pack = self.getpack(filepath) + totalsize += size except Exception as ex: # An exception may be thrown if the pack file is corrupted # somehow. Log a warning but keep going in this case, just @@ -72,8 +73,10 @@ continue self.packs.append(pack) numpacks = len(self.packs) - ui.log("packsizes", "packstore %s has %d packs\n" % (path, numpacks), - numpacks=numpacks) + ui.log("packsizes", "packstore %s has %d packs totaling %s\n" % + (path, numpacks, util.bytecount(totalsize)), + numpacks=numpacks, + totalsize=totalsize) def _getavailablepackfiles(self): suffixlen = len(self.INDEXSUFFIX) @@ -82,7 +85,7 @@ filenames = set() try: for filename, size, stat in osutil.listdir(self.path, stat=True): - files.append((stat.st_mtime, filename)) + files.append((stat.st_mtime, size, filename)) filenames.add(filename) except OSError as ex: if ex.errno != errno.ENOENT: @@ -91,11 +94,11 @@ # Put most recent pack files first since they contain the most recent # info. files = sorted(files, reverse=True) - for mtime, filename in files: + for mtime, size, filename in files: packfilename = '%s%s' % (filename[:-suffixlen], self.PACKSUFFIX) if (filename[-suffixlen:] == self.INDEXSUFFIX and packfilename in filenames): - yield os.path.join(self.path, filename)[:-suffixlen] + yield os.path.join(self.path, filename)[:-suffixlen], size def getpack(self, path): raise NotImplemented() @@ -134,7 +137,8 @@ if now > self.lastrefresh + REFRESHRATE: self.lastrefresh = now previous = set(p.path for p in self.packs) - new = set(self._getavailablepackfiles()) - previous + files = [f for f, size in self._getavailablepackfiles()] + new = set(files) - previous for filepath in new: newpacks.append(self.getpack(filepath))