oCIS: create the hub-groups root before the per-group folder (409 on missing parent)

This commit is contained in:
glass beadian 2026-10-13 05:34:10 +00:00
parent cbbe713dea
commit dec505b83e

View file

@ -144,7 +144,14 @@ export class OcisWebdavClient {
/** MKCOL the group folder; 405 (already exists) is fine. */ /** MKCOL the group folder; 405 (already exists) is fine. */
private async ensureGroupFolder(groupId: string): Promise<void> { private async ensureGroupFolder(groupId: string): Promise<void> {
const url = `${this.config.webdavUrl}/remote.php/dav/files/${encodeURIComponent(this.config.user)}/hub-groups/${encodeURIComponent(groupId)}`; const base = `${this.config.webdavUrl}/remote.php/dav/files/${encodeURIComponent(this.config.user)}`;
// MKCOL returns 409 when the parent collection is missing — create the
// hub-groups root (405 = already exists), then the per-group folder.
const root = await this.fetcher(`${base}/hub-groups`, { method: "MKCOL", headers: this.authHeaders() });
if (!root.ok && root.status !== 405) {
throw new Error(`oCIS folder creation failed with ${root.status}`);
}
const url = `${base}/hub-groups/${encodeURIComponent(groupId)}`;
const response = await this.fetcher(url, { method: "MKCOL", headers: this.authHeaders() }); const response = await this.fetcher(url, { method: "MKCOL", headers: this.authHeaders() });
if (response.ok || response.status === 405) return; if (response.ok || response.status === 405) return;
throw new Error(`oCIS folder creation failed with ${response.status}`); throw new Error(`oCIS folder creation failed with ${response.status}`);