mirror of https://github.com/nextcloud/photos
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:
parent
4e75f6bf26
commit
2f4e8f5a78
|
@ -195,17 +195,20 @@ const actions = {
|
||||||
let face = state.faces[oldName]
|
let face = state.faces[oldName]
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (state.faces[faceName]) {
|
||||||
|
throw new Error('Name already exists')
|
||||||
|
}
|
||||||
await client.moveFile(
|
await client.moveFile(
|
||||||
`/recognize/${getCurrentUser()?.uid}/faces/${oldName}`,
|
`/recognize/${getCurrentUser()?.uid}/faces/${oldName}`,
|
||||||
`/recognize/${getCurrentUser()?.uid}/faces/${faceName}`,
|
`/recognize/${getCurrentUser()?.uid}/faces/${faceName}`,
|
||||||
)
|
)
|
||||||
context.commit('removeFaces', { faceNames: [oldName] })
|
context.commit('removeFaces', { faceNames: [oldName] })
|
||||||
face = { ...face, basename: faceName }
|
face = { ...face, basename: faceName }
|
||||||
|
context.commit('addFaces', { faces: [face] })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(t('photos', 'Failed to rename {oldName} to {faceName}.', { oldName, faceName }), { 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 }))
|
showError(t('photos', 'Failed to rename {oldName} to {faceName}.', { oldName, faceName }))
|
||||||
} finally {
|
throw error
|
||||||
context.commit('addFaces', { faces: [face] })
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue