[BREAKING!]: 서버 재작업 #16

Merged
monoid merged 3 commits from dev into main 2024-10-09 00:18:57 +09:00
8 changed files with 19 additions and 19 deletions
Showing only changes of commit 0bcfc9d74a - Show all commits

View File

@ -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 {
/**

View File

@ -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();

View File

@ -1,4 +1,4 @@
import type { ContentFile } from "../content/mod";
import type { ContentFile } from "../content/mod.ts";
export class ContentList {
/** path map */

View File

@ -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 };

View File

@ -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 };

View File

@ -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;

View File

@ -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 {
// ========

View File

@ -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);
}