Merge "Fix backup-import error when the deleted record in the same db"
This commit is contained in:
commit
5581052415
@ -490,16 +490,18 @@ class API(base.Base):
|
||||
'project_id': context.project_id,
|
||||
'volume_id': IMPORT_VOLUME_ID,
|
||||
'status': fields.BackupStatus.CREATING,
|
||||
'deleted_at': None,
|
||||
'deleted': False,
|
||||
'metadata': {}
|
||||
}
|
||||
|
||||
try:
|
||||
# Try to get the backup with that ID in all projects even among
|
||||
# deleted entries.
|
||||
backup = objects.BackupImport.get_by_id(context,
|
||||
backup_record['id'],
|
||||
read_deleted='yes',
|
||||
project_only=False)
|
||||
backup = objects.BackupImport.get_by_id(
|
||||
context.elevated(read_deleted='yes'),
|
||||
backup_record['id'],
|
||||
project_only=False)
|
||||
|
||||
# If record exists and it's not deleted we cannot proceed with the
|
||||
# import
|
||||
|
@ -6784,8 +6784,10 @@ def worker_destroy(context, **filters):
|
||||
|
||||
@require_context
|
||||
def resource_exists(context, model, resource_id, session=None):
|
||||
conditions = [model.id == resource_id]
|
||||
# Match non deleted resources by the id
|
||||
conditions = [model.id == resource_id, ~model.deleted]
|
||||
if 'no' == context.read_deleted:
|
||||
conditions.append(~model.deleted)
|
||||
# If the context is not admin we limit it to the context's project
|
||||
if is_user_context(context) and hasattr(model, 'project_id'):
|
||||
conditions.append(model.project_id == context.project_id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user