def sync(self): """ Sync the file system with the database. :rtype: None """ data = self.read() isDirty = False for path in data.keys(): if not os.path.exists(path): isDirty = True del data[path] depth = self.recursiveDepth() items = studiolibrary.findItems( self.path(), depth=depth, ) for item in items: path = item.path() if item.path() not in data: isDirty = True data[path] = {} if isDirty: self.save(data) self.dataChanged.emit()
def sync(self): """Sync the file system with the database.""" if not self.path(): logger.info('No path set for syncing data') return data = self.read() for path in data.keys(): if not os.path.exists(path): del data[path] depth = self.recursiveDepth() items = studiolibrary.findItems( self.path(), depth=depth, ) for item in items: path = item.path() itemData = data.get(path, {}) itemData.update(item.itemData()) data[path] = itemData self.postSync(data) self.save(data) self.dataChanged.emit()
def sync(self): """Sync the file system with the database.""" data = self.read() for path in data.keys(): if not os.path.exists(path): del data[path] depth = self.recursiveDepth() items = studiolibrary.findItems( self.path(), depth=depth, ) for item in items: path = item.path() itemData = data.get(path, {}) itemData.update(item.itemData()) data[path] = itemData self.save(data) self.dataChanged.emit()
def sync(self, progressCallback=None): """Sync the file system with the database.""" if not self.path(): logger.info('No path set for syncing data') return if progressCallback: progressCallback("Syncing") data = self.read() for path in data.keys(): if not os.path.exists(path): del data[path] depth = self.recursiveDepth() items = studiolibrary.findItems( self.path(), depth=depth, ) items = list(items) count = len(items) for i, item in enumerate(items): percent = (float(i + 1) / float(count)) if progressCallback: percent *= 100 label = "{0:.0f}%".format(percent) progressCallback(label, percent) path = item.path() itemData = data.get(path, {}) itemData.update(item.createItemData()) data[path] = itemData if progressCallback: progressCallback("Post Callbacks") self.postSync(data) if progressCallback: progressCallback("Saving Cache") self.save(data) self.dataChanged.emit()
def sync(self, percentCallback=lambda message, percent: None): """Sync the file system with the database.""" if not self.path(): logger.info('No path set for syncing data') return if percentCallback: percentCallback("Syncing", -1) data = self.read() for path in data.keys(): if not os.path.exists(path): del data[path] depth = self.recursiveDepth() items = studiolibrary.findItems( self.path(), depth=depth, ) items = list(items) count = len(items) for i, item in enumerate(items): percent = (float(i + 1) / float(count)) percentCallback("", percent) path = item.path() itemData = data.get(path, {}) itemData.update(item.itemData()) data[path] = itemData if percentCallback: percentCallback("Post Sync", -1) self.postSync(data) if percentCallback: percentCallback("Saving Cache", -1) self.save(data) self.dataChanged.emit()