mirror of
https://github.com/captbaritone/webamp.git
synced 2026-01-24 02:36:00 +00:00
27 lines
509 B
JavaScript
27 lines
509 B
JavaScript
const path = require("path");
|
|
const fs = require("fs");
|
|
const config = require("./config");
|
|
|
|
let cache = null;
|
|
|
|
function getCache() {
|
|
if (cache == null) {
|
|
cache = JSON.parse(
|
|
fs.readFileSync(config.cachePath,
|
|
"utf8"
|
|
)
|
|
);
|
|
}
|
|
return cache;
|
|
}
|
|
|
|
function getInfo(md5) {
|
|
return getCache()[md5];
|
|
}
|
|
|
|
function getFilename(md5) {
|
|
const info = getInfo(md5);
|
|
return info.filePaths.map(filepath => path.basename(filepath))[0];
|
|
}
|
|
|
|
module.exports = { getInfo, getCache, getFilename };
|