InpxHashCreator.js 855 B

1234567891011121314151617181920212223242526272829303132
  1. const fs = require('fs-extra');
  2. const utils = require('./utils');
  3. class InpxHashCreator {
  4. constructor(config) {
  5. this.config = config;
  6. }
  7. async getHash() {
  8. const config = this.config;
  9. let inpxFilterHash = '';
  10. if (await fs.pathExists(config.inpxFilterFile))
  11. inpxFilterHash = await utils.getFileHash(config.inpxFilterFile, 'sha256', 'hex');
  12. const joinedHash = this.config.dbVersion + inpxFilterHash +
  13. await utils.getFileHash(config.inpxFile, 'sha256', 'hex');
  14. return utils.getBufHash(joinedHash, 'sha256', 'hex');
  15. }
  16. async getInpxFileHash() {
  17. return (
  18. await fs.pathExists(this.config.inpxFile) ?
  19. await utils.getFileHash(this.config.inpxFile, 'sha256', 'hex') :
  20. ''
  21. );
  22. }
  23. }
  24. module.exports = InpxHashCreator;