def diff(self, toUUID, fromUUID, estimatedSize='None'): if estimatedSize == 'None': return Store.Diff(self.sink, self.vol(toUUID), self.vol(fromUUID)) else: estimatedSize = int(float(estimatedSize)) return Store.Diff(self.sink, self.vol(toUUID), self.vol(fromUUID), estimatedSize, True)
def getEdges(self, fromVol): """ Return the edges available from fromVol. """ if fromVol is None: for toVol in self.paths: yield Store.Diff(self, toVol, fromVol, toVol.size) return if fromVol not in self.paths: return fromBVol = self.butterVolumes[fromVol.uuid] parentUUID = fromBVol.parent_uuid butterDir = os.path.dirname(fromBVol.fullPath) vols = [ vol for vol in self.butterVolumes.values() if vol.parent_uuid == parentUUID or os.path.dirname(vol.fullPath) == butterDir ] changeRate = self._calcChangeRate(vols) for toBVol in vols: if toBVol == fromBVol: continue # This gives a conservative estimate of the size of the diff estimatedSize = self._estimateSize(toBVol, fromBVol, changeRate) toVol = self._btrfsVol2StoreVol(toBVol) yield Store.Diff(self, toVol, fromVol, estimatedSize, sizeIsEstimated=True)
def getEdges(self, fromVol): """ Return the edges available from fromVol. """ diffs = [] for diff_dict in self._client.getEdges(self.toArg.vol(fromVol)): diffs.append( Store.Diff( sink=self, toVol=self.toObj.vol(diff_dict["toVol"]), fromVol=(None if diff_dict["fromVol"] is None else self.toObj.vol(diff_dict["fromVol"])), size=diff_dict["size"], sizeIsEstimated=diff_dict["sizeIsEstimated"], )) return diffs
def _fillVolumesAndPaths(self, paths): """ Fill in paths. :arg paths: = { Store.Volume: ["linux path",]} """ self.diffs = collections.defaultdict((lambda: [])) self.extraKeys = {} for key in self.bucket.list(): if key.name.startswith(theTrashPrefix): continue keyInfo = self._parseKeyName(key.name) if keyInfo is None: if key.name[-1:] != '/': logger.warning("Ignoring '%s' in S3", key.name) continue if keyInfo['type'] == 'info': stream = io.BytesIO() key.get_contents_to_file(stream) Store.Volume.readInfo(stream) continue if keyInfo['from'] == 'None': keyInfo['from'] = None path = self._relativePath("/" + keyInfo['fullpath']) if path is None: continue diff = Store.Diff(self, keyInfo['to'], keyInfo['from'], key.size) logger.debug("Adding %s in %s", diff, path) self.diffs[diff.fromVol].append(diff) paths[diff.toVol].append(path) self.extraKeys[diff] = path
def diff(self, values): return Store.Diff(sink=self.sink, **values)