InpxHashCreator.js 907 B

12345678910111213141516171819202122232425262728
  1. const fs = require('fs-extra');
  2. const utils = require('./utils');
  3. //поправить в случае, если были критические изменения в DbCreator
  4. //иначе будет рассинхронизация между сервером и клиентом на уровне БД
  5. const dbCreatorVersion = '2';
  6. class InpxHashCreator {
  7. constructor(config) {
  8. this.config = config;
  9. }
  10. async getHash() {
  11. const config = this.config;
  12. let inpxFilterHash = '';
  13. if (await fs.pathExists(config.inpxFilterFile))
  14. inpxFilterHash = await utils.getFileHash(config.inpxFilterFile, 'sha256', 'hex');
  15. const joinedHash = dbCreatorVersion + inpxFilterHash +
  16. await utils.getFileHash(config.inpxFile, 'sha256', 'hex');
  17. return utils.getBufHash(joinedHash, 'sha256', 'hex');
  18. }
  19. }
  20. module.exports = InpxHashCreator;