fix: Make mkdir recursive in FileDataAccessor

DataAccessorBasedStore already did the checks to make sure
writing this container is valid and this allows us to
start the server in nested non-existing folders.
This commit is contained in:
Joachim Van Herwegen 2021-02-11 14:14:09 +01:00
parent 49a04c4d0a
commit 30cebec32a

View File

@ -103,7 +103,7 @@ export class FileDataAccessor implements DataAccessor {
public async writeContainer(identifier: ResourceIdentifier, metadata: RepresentationMetadata): Promise<void> { public async writeContainer(identifier: ResourceIdentifier, metadata: RepresentationMetadata): Promise<void> {
const link = await this.resourceMapper.mapUrlToFilePath(identifier); const link = await this.resourceMapper.mapUrlToFilePath(identifier);
try { try {
await fsPromises.mkdir(link.filePath); await fsPromises.mkdir(link.filePath, { recursive: true });
} catch (error: unknown) { } catch (error: unknown) {
// Don't throw if directory already exists // Don't throw if directory already exists
if (!isSystemError(error) || error.code !== 'EEXIST') { if (!isSystemError(error) || error.code !== 'EEXIST') {