From 4f69543d780e828da48e0b6843083c91e549bc21 Mon Sep 17 00:00:00 2001 From: monoid Date: Mon, 11 Jan 2021 20:48:33 +0900 Subject: [PATCH] change hash --- src/content/referrer.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/content/referrer.ts b/src/content/referrer.ts index 32e8146..f4b0395 100644 --- a/src/content/referrer.ts +++ b/src/content/referrer.ts @@ -2,6 +2,7 @@ import {Context, DefaultState, DefaultContext, Middleware, Next} from 'koa'; import Router from 'koa-router'; import {createHash} from 'crypto'; import {promises} from 'fs' +import {extname} from 'path'; /** * content file or directory referrer */ @@ -26,6 +27,7 @@ export const createDefaultClass = (type:string):ContentReferrerConstructor=>{ async getHash():Promise{ const stat = await promises.stat(this.path); const hash = createHash("sha512"); + hash.update(extname(this.type)); hash.update(stat.mode.toString()); //if(this.desc !== undefined) // hash.update(JSON.stringify(this.desc)); @@ -47,4 +49,8 @@ export function createContentReferrer(type:string,path:string,desc?:object){ throw new Error("undefined"); } return new constructorMethod(path,desc); +} +export function getContentRefererConstructor(type:string): ContentReferrerConstructor|undefined{ + const ret = ContstructorTable[type]; + return ret; } \ No newline at end of file