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) {
|
||||
const isPermanent = activeSection === 'trash';
|
||||
await api.deleteFile(file.path, isPermanent);
|
||||
if (isPermanent) {
|
||||
loadTrash();
|
||||
} else {
|
||||
loadFiles(undefined, true);
|
||||
try {
|
||||
await api.deleteFile(file.path, isPermanent);
|
||||
if (isPermanent) {
|
||||
loadTrash();
|
||||
} 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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
@ -202,7 +210,7 @@ class ApiClient {
|
|||
}
|
||||
|
||||
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}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
|
|
@ -278,6 +286,7 @@ class ApiClient {
|
|||
// --- Pinned ---
|
||||
async listPinned() {
|
||||
const res = await this.request('/api/files/pinned');
|
||||
if (!res.ok) throw await res.json();
|
||||
return res.json();
|
||||
}
|
||||
|
||||
|
|
@ -286,16 +295,19 @@ class ApiClient {
|
|||
method: 'POST',
|
||||
body: { path },
|
||||
});
|
||||
if (!res.ok) throw await res.json();
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async getTasks() {
|
||||
const res = await this.request('/api/tasks');
|
||||
if (!res.ok) throw await res.json();
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async getSettings() {
|
||||
const res = await this.request('/api/settings');
|
||||
if (!res.ok) throw await res.json();
|
||||
return res.json();
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue