fix: pass path in query to ensure pathjail picks it up, add explicit error handling UI
All checks were successful
Automated Container Build / build-and-push (push) Successful in 39s
All checks were successful
Automated Container Build / build-and-push (push) Successful in 39s
This commit is contained in:
parent
9807ad6fe5
commit
1a1add48bf
2 changed files with 24 additions and 8 deletions
|
|
@ -647,14 +647,18 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) {
|
||||||
|
|
||||||
async function executeDeleteSingle(file: FileItem) {
|
async function executeDeleteSingle(file: FileItem) {
|
||||||
const isPermanent = activeSection === 'trash';
|
const isPermanent = activeSection === 'trash';
|
||||||
await api.deleteFile(file.path, isPermanent);
|
try {
|
||||||
if (isPermanent) {
|
await api.deleteFile(file.path, isPermanent);
|
||||||
loadTrash();
|
if (isPermanent) {
|
||||||
} else {
|
loadTrash();
|
||||||
loadFiles(undefined, true);
|
} else {
|
||||||
|
loadFiles(undefined, true);
|
||||||
|
}
|
||||||
|
setDeleteConfirm(null);
|
||||||
|
showToast(isPermanent ? `Permanently deleted ${file.name}` : `Deleted ${file.name}`);
|
||||||
|
} catch (err: any) {
|
||||||
|
showToast(`Delete failed: ${err.message}`);
|
||||||
}
|
}
|
||||||
setDeleteConfirm(null);
|
|
||||||
showToast(isPermanent ? `Permanently deleted ${file.name}` : `Deleted ${file.name}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handlePin(file: FileItem) {
|
async function handlePin(file: FileItem) {
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,14 @@ class ApiClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!response.ok && endpoint !== '/api/auth/refresh') {
|
||||||
|
let errorMsg = `HTTP ${response.status}`;
|
||||||
|
try {
|
||||||
|
const errData = await response.clone().json();
|
||||||
|
if (errData.error) errorMsg = errData.error;
|
||||||
|
} catch {}
|
||||||
|
throw new Error(errorMsg);
|
||||||
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -202,7 +210,7 @@ class ApiClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteFile(path: string, permanent: boolean = false) {
|
async deleteFile(path: string, permanent: boolean = false) {
|
||||||
const query = permanent ? '?permanent=true' : '';
|
const query = permanent ? `?permanent=true&path=${encodeURIComponent(path)}` : `?path=${encodeURIComponent(path)}`;
|
||||||
const res = await this.request(`/api/files/${encodeURIComponent(path)}${query}`, {
|
const res = await this.request(`/api/files/${encodeURIComponent(path)}${query}`, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
});
|
});
|
||||||
|
|
@ -278,6 +286,7 @@ class ApiClient {
|
||||||
// --- Pinned ---
|
// --- Pinned ---
|
||||||
async listPinned() {
|
async listPinned() {
|
||||||
const res = await this.request('/api/files/pinned');
|
const res = await this.request('/api/files/pinned');
|
||||||
|
if (!res.ok) throw await res.json();
|
||||||
return res.json();
|
return res.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -286,16 +295,19 @@ class ApiClient {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: { path },
|
body: { path },
|
||||||
});
|
});
|
||||||
|
if (!res.ok) throw await res.json();
|
||||||
return res.json();
|
return res.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTasks() {
|
async getTasks() {
|
||||||
const res = await this.request('/api/tasks');
|
const res = await this.request('/api/tasks');
|
||||||
|
if (!res.ok) throw await res.json();
|
||||||
return res.json();
|
return res.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSettings() {
|
async getSettings() {
|
||||||
const res = await this.request('/api/settings');
|
const res = await this.request('/api/settings');
|
||||||
|
if (!res.ok) throw await res.json();
|
||||||
return res.json();
|
return res.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue