change hash
This commit is contained in:
parent
60b61a8004
commit
4f69543d78
@ -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<string>{
|
||||
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));
|
||||
@ -48,3 +50,7 @@ export function createContentReferrer(type:string,path:string,desc?:object){
|
||||
}
|
||||
return new constructorMethod(path,desc);
|
||||
}
|
||||
export function getContentRefererConstructor(type:string): ContentReferrerConstructor|undefined{
|
||||
const ret = ContstructorTable[type];
|
||||
return ret;
|
||||
}
|
Loading…
Reference in New Issue
Block a user