feat: integrate settings validation API before saving upload path
- saveUploadPath now validates path via POST /api/v2/settings/validate - Shows clear error message if path doesn't exist or isn't writable - Only saves if validation passes (valid: true) - 5 validation checks: format, existence, type, read/write permissions
This commit is contained in:
@@ -1104,6 +1104,21 @@ async function saveUploadPath() {
|
|||||||
saveMessage.value = ''
|
saveMessage.value = ''
|
||||||
saveError.value = false
|
saveError.value = false
|
||||||
try {
|
try {
|
||||||
|
// First validate the path
|
||||||
|
const validateResp = await fetch(`${markbaseUrl.value}/api/v2/settings/validate`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ server: { upload_path: uploadPath.value } })
|
||||||
|
})
|
||||||
|
const validateData = await validateResp.json()
|
||||||
|
if (!validateData.valid) {
|
||||||
|
saveError.value = true
|
||||||
|
saveMessage.value = validateData.message || 'Path validation failed'
|
||||||
|
saving.value = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Path is valid, now save
|
||||||
const resp = await fetch(`${markbaseUrl.value}/api/v2/settings`, {
|
const resp = await fetch(`${markbaseUrl.value}/api/v2/settings`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
|||||||
Reference in New Issue
Block a user