check is name already exists during renaming
This commit is contained in:
@@ -139,6 +139,11 @@
|
|||||||
|
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
if (response.status == 400) {
|
||||||
|
let json_res = await response.json()
|
||||||
|
alert(json_res['msg'])
|
||||||
|
return;
|
||||||
|
}
|
||||||
throw new Error(`Fehlgeschlagen: ${response.status}`)
|
throw new Error(`Fehlgeschlagen: ${response.status}`)
|
||||||
} else {
|
} else {
|
||||||
setTimeout(() => {window.location.reload()}, 500)
|
setTimeout(() => {window.location.reload()}, 500)
|
||||||
|
|||||||
@@ -11,10 +11,20 @@ export async function PUT({ request }) {
|
|||||||
// Vorgang
|
// Vorgang
|
||||||
let vorgang = request.url.split('/').at(-1)
|
let vorgang = request.url.split('/').at(-1)
|
||||||
|
|
||||||
// copy
|
// prepare copy, incl. check if new name exists already
|
||||||
let old_name = data["old_name"]
|
let old_name = data["old_name"]
|
||||||
let src_full_path = `/tatort/${vorgang}/${old_name}`
|
let src_full_path = `/tatort/${vorgang}/${old_name}`
|
||||||
let new_name = `${vorgang}/${data["new_name"]}`
|
let new_name = `${vorgang}/${data["new_name"]}`
|
||||||
|
|
||||||
|
try {
|
||||||
|
let file_stats = await client.statObject('tatort', new_name)
|
||||||
|
return json({ msg: 'Die Datei existiert bereits.' }, { status: 400 })
|
||||||
|
} catch (error) {
|
||||||
|
// continue operation
|
||||||
|
console.log('continue operation')
|
||||||
|
}
|
||||||
|
|
||||||
|
// actual copy operation
|
||||||
await client.copyObject('tatort', new_name, src_full_path)
|
await client.copyObject('tatort', new_name, src_full_path)
|
||||||
|
|
||||||
// delete
|
// delete
|
||||||
|
|||||||
Reference in New Issue
Block a user