Beispiel #1
0
def get_targets(date):
    return FileVersion.find(
        Q('date_created', 'lt', date - DELTA_DATE) &
        Q('status', 'ne', 'cached') &
        Q('metadata.archive', 'exists', True) &
        Q('location', 'ne', None)
    ).iterator()
Beispiel #2
0
def osfstorage_update_metadata(node_addon, payload, **kwargs):
    try:
        version_id = payload['version']
        metadata = payload['metadata']
    except KeyError:
        raise HTTPError(httplib.BAD_REQUEST)

    version = FileVersion.load(version_id)

    if version is None:
        raise HTTPError(httplib.NOT_FOUND)

    version.update_metadata(metadata)

    return {'status': 'success'}
Beispiel #3
0
    def create_version(self, creator, location, metadata=None):
        latest_version = self.get_version()
        version = FileVersion(identifier=self.versions.count() + 1, creator=creator, location=location)

        if latest_version and latest_version.is_duplicate(version):
            return latest_version

        if metadata:
            version.update_metadata(metadata)

        version._find_matching_archive(save=False)

        version.save()
        self.versions.add(version)
        self.save()

        return version
Beispiel #4
0
def osfstorage_update_metadata(node_addon, payload, **kwargs):
    try:
        version_id = payload['version']
        metadata = payload['metadata']
    except KeyError:
        raise HTTPError(httplib.BAD_REQUEST)

    version = FileVersion.load(version_id)

    if version is None:
        raise HTTPError(httplib.NOT_FOUND)

    version.update_metadata(metadata)

    return {'status': 'success'}
Beispiel #5
0
def get_targets(date):
    return FileVersion.find(
        Q('date_created', 'lt', date - DELTA_DATE)
        & Q('status', 'ne', 'cached') & Q('metadata.archive', 'exists', True)
        & Q('location', 'ne', None)).iterator()