diff --git a/src/daemons/server-stats.ts b/src/daemons/server-stats.ts index b82f421779..ee62c32d7e 100644 --- a/src/daemons/server-stats.ts +++ b/src/daemons/server-stats.ts @@ -56,20 +56,12 @@ function cpuUsage() { // MEMORY(excl buffer + cache) STAT async function usedMem() { - try { - const data = await sysUtils.mem(); - return data.active; - } catch (error) { - throw error; - } + const data = await sysUtils.mem(); + return data.active; } // TOTAL MEMORY STAT async function totalMem() { - try { - const data = await sysUtils.mem(); - return data.total; - } catch (error) { - throw error; - } + const data = await sysUtils.mem(); + return data.total; } diff --git a/src/prelude/maybe.ts b/src/prelude/maybe.ts index f9ac95c0b5..0b4b543ca5 100644 --- a/src/prelude/maybe.ts +++ b/src/prelude/maybe.ts @@ -1,19 +1,19 @@ -export interface Maybe { - isJust(): this is Just; +export interface IMaybe { + isJust(): this is IJust; } -export type Just = Maybe & { - get(): T -}; +export interface IJust extends IMaybe { + get(): T; +} -export function just(value: T): Just { +export function just(value: T): IJust { return { isJust: () => true, get: () => value }; } -export function nothing(): Maybe { +export function nothing(): IMaybe { return { isJust: () => false, }; diff --git a/src/queue/processors/db/delete-drive-files.ts b/src/queue/processors/db/delete-drive-files.ts index 491734acc6..4e4eab86b7 100644 --- a/src/queue/processors/db/delete-drive-files.ts +++ b/src/queue/processors/db/delete-drive-files.ts @@ -17,10 +17,9 @@ export async function deleteDriveFiles(job: Bull.Job, done: any): Promise } let deletedCount = 0; - let ended = false; let cursor: any = null; - while (!ended) { + while (true) { const files = await DriveFiles.find({ where: { userId: user.id, @@ -33,7 +32,6 @@ export async function deleteDriveFiles(job: Bull.Job, done: any): Promise }); if (files.length === 0) { - ended = true; job.progress(100); break; } diff --git a/src/queue/processors/db/export-blocking.ts b/src/queue/processors/db/export-blocking.ts index 44025ec960..c4b8c9438d 100644 --- a/src/queue/processors/db/export-blocking.ts +++ b/src/queue/processors/db/export-blocking.ts @@ -33,10 +33,9 @@ export async function exportBlocking(job: Bull.Job, done: any): Promise { const stream = fs.createWriteStream(path, { flags: 'a' }); let exportedCount = 0; - let ended = false; let cursor: any = null; - while (!ended) { + while (true) { const blockings = await Blockings.find({ where: { blockerId: user.id, @@ -49,7 +48,6 @@ export async function exportBlocking(job: Bull.Job, done: any): Promise { }); if (blockings.length === 0) { - ended = true; job.progress(100); break; } diff --git a/src/queue/processors/db/export-following.ts b/src/queue/processors/db/export-following.ts index 81dcf8f93e..9fab5bb21a 100644 --- a/src/queue/processors/db/export-following.ts +++ b/src/queue/processors/db/export-following.ts @@ -33,10 +33,9 @@ export async function exportFollowing(job: Bull.Job, done: any): Promise { const stream = fs.createWriteStream(path, { flags: 'a' }); let exportedCount = 0; - let ended = false; let cursor: any = null; - while (!ended) { + while (true) { const followings = await Followings.find({ where: { followerId: user.id, @@ -49,7 +48,6 @@ export async function exportFollowing(job: Bull.Job, done: any): Promise { }); if (followings.length === 0) { - ended = true; job.progress(100); break; } diff --git a/src/queue/processors/db/export-mute.ts b/src/queue/processors/db/export-mute.ts index f810b6ee8d..b957b48b20 100644 --- a/src/queue/processors/db/export-mute.ts +++ b/src/queue/processors/db/export-mute.ts @@ -33,10 +33,9 @@ export async function exportMute(job: Bull.Job, done: any): Promise { const stream = fs.createWriteStream(path, { flags: 'a' }); let exportedCount = 0; - let ended = false; let cursor: any = null; - while (!ended) { + while (true) { const mutes = await Mutings.find({ where: { muterId: user.id, @@ -49,7 +48,6 @@ export async function exportMute(job: Bull.Job, done: any): Promise { }); if (mutes.length === 0) { - ended = true; job.progress(100); break; } diff --git a/src/queue/processors/db/export-notes.ts b/src/queue/processors/db/export-notes.ts index eaa5caf63f..d03a216a59 100644 --- a/src/queue/processors/db/export-notes.ts +++ b/src/queue/processors/db/export-notes.ts @@ -46,10 +46,9 @@ export async function exportNotes(job: Bull.Job, done: any): Promise { }); let exportedNotesCount = 0; - let ended = false; let cursor: any = null; - while (!ended) { + while (true) { const notes = await Notes.find({ where: { userId: user.id, @@ -62,7 +61,6 @@ export async function exportNotes(job: Bull.Job, done: any): Promise { }); if (notes.length === 0) { - ended = true; job.progress(100); break; } diff --git a/src/remote/activitypub/request.ts b/src/remote/activitypub/request.ts index 7dc48c15e3..897dd9acac 100644 --- a/src/remote/activitypub/request.ts +++ b/src/remote/activitypub/request.ts @@ -41,7 +41,7 @@ export default async (user: ILocalUser, url: string, object: any) => { userId: user.id }).then(ensure); - const _ = new Promise((resolve, reject) => { + await new Promise((resolve, reject) => { const req = request({ protocol, hostname: addr, @@ -88,8 +88,6 @@ export default async (user: ILocalUser, url: string, object: any) => { req.end(data); }); - await _; - //#region Log publishApLogStream({ direction: 'out',