FilesystemBackend: Fix functionContext logging

This commit adds a few missing `functionContext` parameters in calls to
`this.logger` and fixes a copy-paste error in `ensureDirectory`

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-04-22 21:58:03 +02:00
parent e7cdc30eff
commit 678f69f562
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3

View file

@ -58,19 +58,24 @@ export class FilesystemBackend implements MediaBackend {
}
private async ensureDirectory(): Promise<void> {
this.logger.debug(
`Ensuring presence of directory at ${this.uploadDirectory}`,
'ensureDirectory',
);
try {
await fs.access(this.uploadDirectory);
} catch (e) {
try {
this.logger.debug(
`The directory '${this.uploadDirectory}' can't be accessed. Trying to create the directory`,
'ensureDirectory',
);
await fs.mkdir(this.uploadDirectory);
} catch (e) {
this.logger.error(
(e as Error).message,
(e as Error).stack,
'deleteFile',
'ensureDirectory',
);
throw new MediaBackendError(
`Could not create '${this.uploadDirectory}'`,