mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-08 10:22:47 -04:00
Merge pull request #936 from hedgedoc/maint/stronger_lint_checks
This commit is contained in:
commit
a92096034d
41 changed files with 309 additions and 187 deletions
|
@ -38,7 +38,7 @@ export class FilesystemBackend implements MediaBackend {
|
|||
await fs.writeFile(filePath, buffer, null);
|
||||
return ['/' + filePath, null];
|
||||
} catch (e) {
|
||||
this.logger.error(e.message, e.stack, 'saveFile');
|
||||
this.logger.error((e as Error).message, (e as Error).stack, 'saveFile');
|
||||
throw new MediaBackendError(`Could not save '${filePath}'`);
|
||||
}
|
||||
}
|
||||
|
@ -46,9 +46,9 @@ export class FilesystemBackend implements MediaBackend {
|
|||
async deleteFile(fileName: string, _: BackendData): Promise<void> {
|
||||
const filePath = this.getFilePath(fileName);
|
||||
try {
|
||||
return fs.unlink(filePath);
|
||||
return await fs.unlink(filePath);
|
||||
} catch (e) {
|
||||
this.logger.error(e.message, e.stack, 'deleteFile');
|
||||
this.logger.error((e as Error).message, (e as Error).stack, 'deleteFile');
|
||||
throw new MediaBackendError(`Could not delete '${filePath}'`);
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ export class FilesystemBackend implements MediaBackend {
|
|||
return join(this.uploadDirectory, fileName);
|
||||
}
|
||||
|
||||
private async ensureDirectory() {
|
||||
private async ensureDirectory(): Promise<void> {
|
||||
try {
|
||||
await fs.access(this.uploadDirectory);
|
||||
} catch (e) {
|
||||
|
@ -67,7 +67,11 @@ export class FilesystemBackend implements MediaBackend {
|
|||
);
|
||||
await fs.mkdir(this.uploadDirectory);
|
||||
} catch (e) {
|
||||
this.logger.error(e.message, e.stack, 'deleteFile');
|
||||
this.logger.error(
|
||||
(e as Error).message,
|
||||
(e as Error).stack,
|
||||
'deleteFile',
|
||||
);
|
||||
throw new MediaBackendError(
|
||||
`Could not create '${this.uploadDirectory}'`,
|
||||
);
|
||||
|
|
|
@ -4,6 +4,12 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
/* eslint-disable
|
||||
@typescript-eslint/no-unsafe-call,
|
||||
@typescript-eslint/no-unsafe-member-access,
|
||||
@typescript-eslint/no-unsafe-return,
|
||||
@typescript-eslint/require-await */
|
||||
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||
|
@ -96,7 +102,7 @@ describe('MediaService', () => {
|
|||
});
|
||||
|
||||
describe('saveFile', () => {
|
||||
beforeEach(async () => {
|
||||
beforeEach(() => {
|
||||
const user = User.create('hardcoded', 'Testy') as User;
|
||||
const alias = 'alias';
|
||||
const note = Note.create(user, alias);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue