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 3de960a25e..cedfdef236 100644 --- a/src/queue/processors/db/delete-drive-files.ts +++ b/src/queue/processors/db/delete-drive-files.ts @@ -16,10 +16,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 DriveFile.find({ userId: user._id, ...(cursor ? { _id: { $gt: cursor } } : {}) @@ -31,7 +30,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 7f32c06472..73128aa41a 100644 --- a/src/queue/processors/db/export-blocking.ts +++ b/src/queue/processors/db/export-blocking.ts @@ -32,10 +32,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 Blocking.find({ blockerId: user._id, ...(cursor ? { _id: { $gt: cursor } } : {}) @@ -47,7 +46,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 019414072a..8387baa86d 100644 --- a/src/queue/processors/db/export-following.ts +++ b/src/queue/processors/db/export-following.ts @@ -32,10 +32,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 Following.find({ followerId: user._id, ...(cursor ? { _id: { $gt: cursor } } : {}) @@ -47,7 +46,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 5ded7cf651..517c2bee7f 100644 --- a/src/queue/processors/db/export-mute.ts +++ b/src/queue/processors/db/export-mute.ts @@ -32,10 +32,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 Mute.find({ muterId: user._id, ...(cursor ? { _id: { $gt: cursor } } : {}) @@ -47,7 +46,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 8f3cdc5b99..bcf664fdb5 100644 --- a/src/queue/processors/db/export-notes.ts +++ b/src/queue/processors/db/export-notes.ts @@ -42,10 +42,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 Note.find({ userId: user._id, ...(cursor ? { _id: { $gt: cursor } } : {}) @@ -57,7 +56,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 7fd05f776e..df6058d6b6 100644 --- a/src/remote/activitypub/request.ts +++ b/src/remote/activitypub/request.ts @@ -35,7 +35,7 @@ export default async (user: ILocalUser, url: string, object: any) => { const addr = await resolveAddr(hostname); if (!addr) return; - const _ = new Promise((resolve, reject) => { + await new Promise((resolve, reject) => { const req = request({ protocol, hostname: addr, @@ -82,8 +82,6 @@ export default async (user: ILocalUser, url: string, object: any) => { req.end(data); }); - await _; - //#region Log publishApLogStream({ direction: 'out',