Compare commits
2 commits
6e233991b4
...
f8e2930ec1
Author | SHA1 | Date | |
---|---|---|---|
f8e2930ec1 | |||
516d7f5fbd |
5 changed files with 22 additions and 25 deletions
1
.npmrc
1
.npmrc
|
@ -1 +1,2 @@
|
||||||
link-workspace-packages=true
|
link-workspace-packages=true
|
||||||
|
@jsr:registry=https://npm.jsr.io
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@std/async": "npm:@jsr/std__async@^1.0.12",
|
||||||
"@zip.js/zip.js": "^2.7.52",
|
"@zip.js/zip.js": "^2.7.52",
|
||||||
"better-sqlite3": "^9.6.0",
|
"better-sqlite3": "^9.6.0",
|
||||||
"chokidar": "^3.6.0",
|
"chokidar": "^3.6.0",
|
||||||
|
|
|
@ -3,6 +3,7 @@ import type { DocumentBody } from "dbtype";
|
||||||
import { readZip } from "../util/zipwrap.ts";
|
import { readZip } from "../util/zipwrap.ts";
|
||||||
import { type ContentConstructOption, createDefaultClass, registerContentReferrer } from "./file.ts";
|
import { type ContentConstructOption, createDefaultClass, registerContentReferrer } from "./file.ts";
|
||||||
import { TextWriter } from "@zip.js/zip.js";
|
import { TextWriter } from "@zip.js/zip.js";
|
||||||
|
import { retry } from "@std/async"
|
||||||
|
|
||||||
type ComicType = "doujinshi" | "artist cg" | "manga" | "western";
|
type ComicType = "doujinshi" | "artist cg" | "manga" | "western";
|
||||||
interface ComicDesc {
|
interface ComicDesc {
|
||||||
|
@ -43,8 +44,16 @@ export class ComicReferrer extends createDefaultClass("comic") {
|
||||||
.then(() => zip.handle.close());
|
.then(() => zip.handle.close());
|
||||||
}
|
}
|
||||||
|
|
||||||
async createDocumentBody(): Promise<DocumentBody> {
|
override async createDocumentBody(): Promise<DocumentBody> {
|
||||||
await this.initDesc();
|
await retry(async () => {
|
||||||
|
await this.initDesc();
|
||||||
|
}, {
|
||||||
|
jitter: 0.5,
|
||||||
|
maxAttempts: 5,
|
||||||
|
minTimeout: 10,
|
||||||
|
maxTimeout: 1000,
|
||||||
|
multiplier: 2,
|
||||||
|
});
|
||||||
const basebody = await super.createDocumentBody();
|
const basebody = await super.createDocumentBody();
|
||||||
this.desc?.title;
|
this.desc?.title;
|
||||||
if (this.desc === undefined) {
|
if (this.desc === undefined) {
|
||||||
|
|
|
@ -12,29 +12,6 @@ export type {
|
||||||
DBDocument
|
DBDocument
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MetaContentBody = {
|
|
||||||
title: "string",
|
|
||||||
content_type: "string",
|
|
||||||
basepath: "string",
|
|
||||||
filename: "string",
|
|
||||||
content_hash: "string",
|
|
||||||
additional: "object",
|
|
||||||
tags: "string[]",
|
|
||||||
};
|
|
||||||
|
|
||||||
export const isDocBody = (c: unknown): c is DocumentBody => {
|
|
||||||
return check_type<DocumentBody>(c, MetaContentBody);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const isDoc = (c: unknown): c is Document => {
|
|
||||||
if (typeof c !== "object" || c === null) return false;
|
|
||||||
if ("id" in c && typeof c.id === "number") {
|
|
||||||
const { id, ...rest } = c;
|
|
||||||
return isDocBody(rest);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface DocumentAccessor {
|
export interface DocumentAccessor {
|
||||||
/**
|
/**
|
||||||
* rescan document
|
* rescan document
|
||||||
|
|
9
pnpm-lock.yaml
generated
9
pnpm-lock.yaml
generated
|
@ -169,6 +169,9 @@ importers:
|
||||||
|
|
||||||
packages/server:
|
packages/server:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@std/async':
|
||||||
|
specifier: npm:@jsr/std__async@^1.0.12
|
||||||
|
version: '@jsr/std__async@1.0.12'
|
||||||
'@zip.js/zip.js':
|
'@zip.js/zip.js':
|
||||||
specifier: ^2.7.52
|
specifier: ^2.7.52
|
||||||
version: 2.7.52
|
version: 2.7.52
|
||||||
|
@ -782,6 +785,9 @@ packages:
|
||||||
'@jridgewell/trace-mapping@0.3.25':
|
'@jridgewell/trace-mapping@0.3.25':
|
||||||
resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==}
|
resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==}
|
||||||
|
|
||||||
|
'@jsr/std__async@1.0.12':
|
||||||
|
resolution: {integrity: sha512-NUaSOcwMetVeVkIqet2Ammy2A5YxG8ViFxryBbTaC4h7l/cgAkU59U3zF58ek4Y8HZ0Nx5De7qBptPfp62kcgw==, tarball: https://npm.jsr.io/~/11/@jsr/std__async/1.0.12.tgz}
|
||||||
|
|
||||||
'@nodelib/fs.scandir@2.1.5':
|
'@nodelib/fs.scandir@2.1.5':
|
||||||
resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==}
|
resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==}
|
||||||
engines: {node: '>= 8'}
|
engines: {node: '>= 8'}
|
||||||
|
@ -2706,6 +2712,7 @@ packages:
|
||||||
node-domexception@1.0.0:
|
node-domexception@1.0.0:
|
||||||
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
|
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
|
||||||
engines: {node: '>=10.5.0'}
|
engines: {node: '>=10.5.0'}
|
||||||
|
deprecated: Use your platform's native DOMException instead
|
||||||
|
|
||||||
node-fetch@3.3.2:
|
node-fetch@3.3.2:
|
||||||
resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==}
|
resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==}
|
||||||
|
@ -3970,6 +3977,8 @@ snapshots:
|
||||||
'@jridgewell/resolve-uri': 3.1.2
|
'@jridgewell/resolve-uri': 3.1.2
|
||||||
'@jridgewell/sourcemap-codec': 1.5.0
|
'@jridgewell/sourcemap-codec': 1.5.0
|
||||||
|
|
||||||
|
'@jsr/std__async@1.0.12': {}
|
||||||
|
|
||||||
'@nodelib/fs.scandir@2.1.5':
|
'@nodelib/fs.scandir@2.1.5':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@nodelib/fs.stat': 2.0.5
|
'@nodelib/fs.stat': 2.0.5
|
||||||
|
|
Loading…
Add table
Reference in a new issue