oCIS: create the hub-groups root before the per-group folder (409 on missing parent)
This commit is contained in:
parent
cbbe713dea
commit
dec505b83e
1 changed files with 8 additions and 1 deletions
|
|
@ -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}`);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue