Fix renaming faces: Do not delete existing face when renaming

fixes https://github.com/nextcloud/recognize/issues/408

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
Marcel Klehr 2023-01-07 17:28:33 +01:00
parent 4e75f6bf26
commit 2f4e8f5a78
1 changed files with 5 additions and 2 deletions

View File

@ -195,17 +195,20 @@ const actions = {
let face = state.faces[oldName]
try {
if (state.faces[faceName]) {
throw new Error('Name already exists')
}
await client.moveFile(
`/recognize/${getCurrentUser()?.uid}/faces/${oldName}`,
`/recognize/${getCurrentUser()?.uid}/faces/${faceName}`,
)
context.commit('removeFaces', { faceNames: [oldName] })
face = { ...face, basename: faceName }
context.commit('addFaces', { faces: [face] })
} catch (error) {
logger.error(t('photos', 'Failed to rename {oldName} to {faceName}.', { oldName, faceName }), { error })
showError(t('photos', 'Failed to rename {oldName} to {faceName}.', { oldName, faceName }))
} finally {
context.commit('addFaces', { faces: [face] })
throw error
}
},