summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/FileInfoService.ts
diff options
context:
space:
mode:
authorwoxtu <woxtup@gmail.com>2023-07-27 09:04:19 +0900
committerGitHub <noreply@github.com>2023-07-27 09:04:19 +0900
commitcb0fa9a8ab168f5e66ff324d730df7d33d8934d1 (patch)
treef5827e0178babdf589dbad8c83e9a0d5d5801ae5 /packages/backend/src/core/FileInfoService.ts
parentrefactor: forkでデフォルトのノート文字数を変更した場合、... (diff)
downloadsharkey-cb0fa9a8ab168f5e66ff324d730df7d33d8934d1.tar.gz
sharkey-cb0fa9a8ab168f5e66ff324d730df7d33d8934d1.tar.bz2
sharkey-cb0fa9a8ab168f5e66ff324d730df7d33d8934d1.zip
Use promises API (#11351)
Diffstat (limited to 'packages/backend/src/core/FileInfoService.ts')
-rw-r--r--packages/backend/src/core/FileInfoService.ts10
1 files changed, 3 insertions, 7 deletions
diff --git a/packages/backend/src/core/FileInfoService.ts b/packages/backend/src/core/FileInfoService.ts
index d43575b336..1028d3760e 100644
--- a/packages/backend/src/core/FileInfoService.ts
+++ b/packages/backend/src/core/FileInfoService.ts
@@ -1,8 +1,7 @@
import * as fs from 'node:fs';
import * as crypto from 'node:crypto';
import { join } from 'node:path';
-import * as stream from 'node:stream';
-import * as util from 'node:util';
+import * as stream from 'node:stream/promises';
import { Injectable } from '@nestjs/common';
import { FSWatcher } from 'chokidar';
import * as fileType from 'file-type';
@@ -16,8 +15,6 @@ import { createTempDir } from '@/misc/create-temp.js';
import { AiService } from '@/core/AiService.js';
import { bindThis } from '@/decorators.js';
-const pipeline = util.promisify(stream.pipeline);
-
export type FileInfo = {
size: number;
md5: string;
@@ -371,8 +368,7 @@ export class FileInfoService {
*/
@bindThis
public async getFileSize(path: string): Promise<number> {
- const getStat = util.promisify(fs.stat);
- return (await getStat(path)).size;
+ return (await fs.promises.stat(path)).size;
}
/**
@@ -381,7 +377,7 @@ export class FileInfoService {
@bindThis
private async calcHash(path: string): Promise<string> {
const hash = crypto.createHash('md5').setEncoding('hex');
- await pipeline(fs.createReadStream(path), hash);
+ await stream.pipeline(fs.createReadStream(path), hash);
return hash.read();
}