diff --git a/browse/js/loader.js b/browse/js/loader.js index 3116be3..eb473ca 100644 --- a/browse/js/loader.js +++ b/browse/js/loader.js @@ -62,12 +62,24 @@ // Fetch children of a directory in server mode. // path must end with '/' so the request hits the directory route. + // + // 404 is treated as "empty directory" rather than a hard error. + // A directory that doesn't exist on the server (e.g. a fresh + // project's working/ before any drafts have been created, or a + // dir deleted between listing and expand) is functionally + // indistinguishable from an empty one for tree-rendering purposes. + // Server-side, zddc-server already returns 200 + [] for canonical + // project folders that are missing on disk; this fallback covers + // the same UX for anything else and for non-zddc-server backends. async function fetchServerChildren(path) { if (!path.endsWith('/')) path += '/'; var resp = await fetch(path, { headers: { 'Accept': 'application/json' }, credentials: 'same-origin' }); + if (resp.status === 404) { + return []; + } if (!resp.ok) { throw new Error('HTTP ' + resp.status + ' fetching ' + path); }