def main(): for each in OsfStorageFileVersion.find( Q('size', 'eq', None) & Q('status', 'ne', 'cached') & Q('location.object', 'exists', True)): logger.info('Updating metadata for OsfStorageFileVersion {}'.format( each._id)) if 'dry' not in sys.argv: each.update_metadata(each.metadata)
def main(): for each in OsfStorageFileVersion.find( Q('size', 'eq', None) & Q('status', 'ne', 'cached') & Q('location.object', 'exists', True) ): logger.info('Updating metadata for OsfStorageFileVersion {}'.format(each._id)) if 'dry' not in sys.argv: each.update_metadata(each.metadata)
def create_version(self, creator, location, metadata=None): latest_version = self.get_version() version = OsfStorageFileVersion(creator=creator, location=location) if latest_version and latest_version.is_duplicate(version): if self.is_deleted: self.undelete(Auth(creator)) return latest_version if metadata: version.update_metadata(metadata) version.save() self.versions.append(version) self.is_deleted = False self.save() self.log( Auth(creator), NodeLog.FILE_UPDATED if len(self.versions) > 1 else NodeLog.FILE_ADDED, ) return version