fix: Prevent setRepresentation crash if there is no root container

This commit is contained in:
Joachim Van Herwegen
2021-02-11 12:09:04 +01:00
parent c05933f652
commit 6424b07fc6
2 changed files with 11 additions and 1 deletions

View File

@@ -385,7 +385,9 @@ export class DataAccessorBasedStore implements ResourceStore {
} catch (error: unknown) {
if (NotFoundHttpError.isInstance(error)) {
// Make sure the parent exists first
await this.createRecursiveContainers(this.identifierStrategy.getParentContainer(container));
if (!this.identifierStrategy.isRootContainer(container)) {
await this.createRecursiveContainers(this.identifierStrategy.getParentContainer(container));
}
await this.writeData(container, new BasicRepresentation([], container), true);
} else {
throw error;