better code: removed unused code

Massimo Melina committed May 2, 2023 at 12:10 UTC 91d3d0b3aa1304630061ece1a62bdbd12b646dfc
2 files changed -7
src/log.ts
-2
@@ -7,7 +7,6 @@ import { createWriteStream, renameSync } from 'fs'
7 import * as util from 'util'
8 import { stat } from 'fs/promises'
9 import { DAY } from './const'
10 -import events from './events'
10 import _ from 'lodash'
11 import { prepareFolder } from './util-files'
12 import { getCurrentUsername } from './perm'
@@ -100,7 +99,6 @@ export function log(): Koa.Middleware {
99 const date = a[2]+'/'+a[1]+'/'+a[3]+':'+a[4]+' '+a[5]?.slice(3)
100 const user = getCurrentUsername(ctx)
101 const length = ctx.state.length ?? ctx.length
103 - events.emit(logger.name, Object.assign(_.pick(ctx, ['ip', 'method','status']), { length, user, ts: now, uri: ctx.path }))
102 debounce(() => // once in a while we check if the file is still good (not deleted, etc), or we'll reopen it
103 stat(logger.path).catch(() => logger.reopen())) // async = smoother but we may lose some entries
104 stream!.write(util.format( format,
src/util-files.ts
-5
@@ -16,11 +16,6 @@ export async function isDirectory(path: string) {
16 catch { return false }
17 }
18
19 -export async function isFile(path: string) {
20 - try { return (await fs.stat(path)).isFile() }
21 - catch { return false }
22 -}
23 -
19 export async function readFileBusy(path: string): Promise<string> {
20 return fs.readFile(path, 'utf8').catch(e => {
21 if ((e as any)?.code !== 'EBUSY')