Merge pull request #1170 from hedgedoc/fix/fs_backend_logging

FilesystemBackend: Fix functionContext logging
This commit is contained in:
David Mehren 2021-04-22 22:45:38 +02:00 committed by GitHub
commit d0aa73dfb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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