Skip to content

Commit ce20c4c

Browse files
committed
Cache uses now hash-sum instead of hashids
1 parent 069901d commit ce20c4c

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

include/file-config.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ const fs = require('fs');
22
const path = require('path');
33
const config = require('./config');
44
const yaml = require('read-yaml');
5-
const Hashids = require('hashids');
6-
const hashids = new Hashids();
5+
const hash = require('hash-sum');
76

87
const globalConfigDir = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'] + '/.gtt';
98
const globalConfigFile = globalConfigDir + '/config.yml';
@@ -82,16 +81,16 @@ class fileConfig extends config {
8281
}
8382

8483
_cacheGet(key) {
85-
let file = this.cacheDir + '/' + hashids.encode(key);
84+
let file = this.cacheDir + '/' + hash(key);
8685
if (!fs.existsSync(file)) return false;
8786

8887
return JSON.parse(fs.readFileSync(file));
8988
}
9089

9190
_cacheSet(key, value) {
92-
let file = this.cacheDir + '/' + hashids.encode(key);
91+
let file = this.cacheDir + '/' + hash(key);
9392
if (fs.existsSync(file)) fs.unlinkSync(file);
94-
fs.appendFileSync(file, JSON.stringify(value));
93+
fs.appendFile(file, JSON.stringify(value), () => {});
9594

9695
return value;
9796
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"commander": "^2.9.0",
2626
"csv-string": "^2.3.2",
2727
"find-in-files": "^0.4.0",
28+
"hash-sum": "^1.0.2",
2829
"hashids": "^1.1.1",
2930
"markdown-pdf": "^8.0.0",
3031
"markdown-table": "^1.1.0",

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,10 @@ has-ansi@^2.0.0:
370370
dependencies:
371371
ansi-regex "^2.0.0"
372372

373+
hash-sum@^1.0.2:
374+
version "1.0.2"
375+
resolved "https://registry.yarnpkg.com/hash-sum/-/hash-sum-1.0.2.tgz#33b40777754c6432573c120cc3808bbd10d47f04"
376+
373377
hasha@~2.2.0:
374378
version "2.2.0"
375379
resolved "https://registry.yarnpkg.com/hasha/-/hasha-2.2.0.tgz#78d7cbfc1e6d66303fe79837365984517b2f6ee1"

0 commit comments

Comments
 (0)