diff --git a/packages/server/src/SettingConfig.ts b/packages/server/src/SettingConfig.ts index a59944e..fe08b33 100644 --- a/packages/server/src/SettingConfig.ts +++ b/packages/server/src/SettingConfig.ts @@ -1,6 +1,6 @@ import { randomBytes } from "node:crypto"; import { existsSync, readFileSync, writeFileSync } from "node:fs"; -import type { Permission } from "./permission/permission"; +import type { Permission } from "./permission/permission.ts"; export interface SettingConfig { /** diff --git a/packages/server/src/database.ts b/packages/server/src/database.ts index 997fe9f..725d947 100644 --- a/packages/server/src/database.ts +++ b/packages/server/src/database.ts @@ -1,6 +1,4 @@ -import { existsSync } from "node:fs"; -import { get_setting } from "./SettingConfig"; -import { getKysely } from "./db/kysely"; +import { getKysely } from "./db/kysely.ts"; export async function connectDB() { const kysely = getKysely(); diff --git a/packages/server/src/diff/content_list.ts b/packages/server/src/diff/content_list.ts index 9e3f7f8..600a581 100644 --- a/packages/server/src/diff/content_list.ts +++ b/packages/server/src/diff/content_list.ts @@ -1,4 +1,4 @@ -import type { ContentFile } from "../content/mod"; +import type { ContentFile } from "../content/mod.ts"; export class ContentList { /** path map */ diff --git a/packages/server/src/diff/diff.ts b/packages/server/src/diff/diff.ts index 3f69f50..eeea3cb 100644 --- a/packages/server/src/diff/diff.ts +++ b/packages/server/src/diff/diff.ts @@ -1,7 +1,7 @@ import asyncPool from "tiny-async-pool"; -import type { DocumentAccessor } from "../model/doc"; -import { ContentDiffHandler } from "./content_handler"; -import type { IDiffWatcher } from "./watcher"; +import type { DocumentAccessor } from "../model/doc.ts"; +import { ContentDiffHandler } from "./content_handler.ts"; +import type { IDiffWatcher } from "./watcher.ts"; export class DiffManager { watching: { [content_type: string]: ContentDiffHandler }; diff --git a/packages/server/src/diff/router.ts b/packages/server/src/diff/router.ts index 41ab912..c3be4f2 100644 --- a/packages/server/src/diff/router.ts +++ b/packages/server/src/diff/router.ts @@ -1,9 +1,9 @@ import type Koa from "koa"; import Router from "koa-router"; -import type { ContentFile } from "../content/mod"; -import { AdminOnlyMiddleware } from "../permission/permission"; -import { sendError } from "../route/error_handler"; -import type { DiffManager } from "./diff"; +import type { ContentFile } from "../content/mod.ts"; +import { AdminOnlyMiddleware } from "../permission/permission.ts"; +import { sendError } from "../route/error_handler.ts"; +import type { DiffManager } from "./diff.ts"; function content_file_to_return(x: ContentFile) { return { path: x.path, type: x.type }; diff --git a/packages/server/src/diff/watcher.ts b/packages/server/src/diff/watcher.ts index 70b01c8..62e306a 100644 --- a/packages/server/src/diff/watcher.ts +++ b/packages/server/src/diff/watcher.ts @@ -2,7 +2,7 @@ import type event from "node:events"; import { FSWatcher, watch } from "node:fs"; import { promises } from "node:fs"; import { join } from "node:path"; -import type { DocumentAccessor } from "../model/doc"; +import type { DocumentAccessor } from "../model/doc.ts"; const readdir = promises.readdir; diff --git a/packages/server/src/permission/permission.ts b/packages/server/src/permission/permission.ts index 8229316..4632ef6 100644 --- a/packages/server/src/permission/permission.ts +++ b/packages/server/src/permission/permission.ts @@ -1,6 +1,6 @@ import type Koa from "koa"; -import type { UserState } from "../login"; -import { sendError } from "../route/error_handler"; +import type { UserState } from "../login.ts"; +import { sendError } from "../route/error_handler.ts"; export enum Permission { // ======== diff --git a/packages/server/src/util/oshash.ts b/packages/server/src/util/oshash.ts index 3584e0a..92a6a45 100644 --- a/packages/server/src/util/oshash.ts +++ b/packages/server/src/util/oshash.ts @@ -24,19 +24,21 @@ export async function oshash( } // read first and last chunk - const firstChunk = Buffer.alloc(chunkSize); + const firstChunk = new Uint8Array(chunkSize); await fd.read(firstChunk, 0, chunkSize, 0); - const lastChunk = Buffer.alloc(chunkSize); + const lastChunk = new Uint8Array(chunkSize); await fd.read(lastChunk, 0, chunkSize, st.size - chunkSize); // iterate over first and last chunk. // for each uint64_t, add it to the hash. + const firstChunkView = new DataView(firstChunk.buffer); for (let i = 0; i < chunkSize; i += 8){ - hash += firstChunk.readBigUInt64LE(i); + hash += firstChunkView.getBigUint64(i, true); // prevent overflow hash = (hash & 0xFFFFFFFFFFFFFFFFn); } + const lastChunkView = new DataView(lastChunk.buffer); for (let i = 0; i < chunkSize; i += 8){ - hash += lastChunk.readBigUInt64LE(i); + hash += lastChunkView.getBigUint64(i, true); // prevent overflow hash = (hash & 0xFFFFFFFFFFFFFFFFn); }