fix(core): update
This commit is contained in:
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartfile',
|
||||
version: '10.0.5',
|
||||
version: '10.0.6',
|
||||
description: 'offers smart ways to work with files in nodejs'
|
||||
}
|
||||
|
@ -237,6 +237,21 @@ export class Smartfile extends plugins.smartjson.Smartjson {
|
||||
return false;
|
||||
}
|
||||
|
||||
public async getHash(typeArg: 'path' | 'content' | 'all' = 'all') {
|
||||
const pathHash = await plugins.smarthash.sha256FromString(this.path);
|
||||
const contentHash = await plugins.smarthash.sha256FromBuffer(this.contentBuffer);
|
||||
const combinedHash = await plugins.smarthash.sha256FromString(pathHash + contentHash);
|
||||
switch(typeArg) {
|
||||
case 'path':
|
||||
return pathHash;
|
||||
case 'content':
|
||||
return contentHash;
|
||||
case 'all':
|
||||
default:
|
||||
return combinedHash;
|
||||
}
|
||||
}
|
||||
|
||||
// update things
|
||||
public updateFileName(fileNameArg: string) {
|
||||
const oldFileName = this.parsedPath.base;
|
||||
|
@ -214,7 +214,7 @@ export const fileTreeToHash = async (dirPathArg: string, miniMatchFilter: string
|
||||
const fileTreeObject = await fileTreeToObject(dirPathArg, miniMatchFilter);
|
||||
let combinedString = '';
|
||||
for (const smartfile of fileTreeObject) {
|
||||
combinedString += smartfile.contentBuffer.toString();
|
||||
combinedString += await smartfile.getHash();
|
||||
}
|
||||
const hash = await plugins.smarthash.sha256FromString(combinedString);
|
||||
return hash;
|
||||
|
Reference in New Issue
Block a user