Added soft-delete to the files schema.
This allows us to soft-delete orphan files, at least until we know that the orphan file detection is solid and can really be trusted.
This commit is contained in:
parent
ce59bc3335
commit
16bf193b0e
@ -720,11 +720,12 @@ tokens = {
|
||||
}
|
||||
|
||||
files = {
|
||||
'schema': files_schema,
|
||||
'resource_methods': ['GET', 'POST'],
|
||||
'item_methods': ['GET', 'PATCH'],
|
||||
'public_methods': ['GET'],
|
||||
'public_item_methods': ['GET'],
|
||||
'schema': files_schema
|
||||
'soft_delete': True,
|
||||
}
|
||||
|
||||
groups = {
|
||||
|
@ -544,7 +544,8 @@ def _find_orphan_files(project_id: bson.ObjectId) -> typing.Set[bson.ObjectId]:
|
||||
|
||||
# Get all file IDs that belong to this project.
|
||||
files_coll = current_app.db('files')
|
||||
cursor = files_coll.find({'project': project_id}, projection={'_id': 1})
|
||||
file_filter = {'project': project_id, '_deleted': {'$ne': True}}
|
||||
cursor = files_coll.find(file_filter, projection={'_id': 1})
|
||||
file_ids = {doc['_id'] for doc in cursor}
|
||||
if not file_ids:
|
||||
log.debug('Project %s has no files', project_id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user