zephyr-agent
Version:
Zephyr plugin agent
38 lines (37 loc) • 1.34 kB
JavaScript
import "node:module";
import { getApplicationHashList } from "../edge-requests/get-application-hash-list.mjs";
import { getCacheKey } from "./get-cache-key.mjs";
import { getAppHashCache, setAppHashCache } from "../node-persist/hash-cache.mjs";
async function get_hash_list(application_uid) {
const cacheKey = await getCacheKey(application_uid);
const local_hash_list = await getAppHashCache(cacheKey);
if (local_hash_list) return {
hash_set: new Set(local_hash_list.hashes)
};
const remote_hash_list = await getApplicationHashList({
application_uid
});
if (remote_hash_list) {
await setAppHashCache(cacheKey, remote_hash_list);
return {
hash_set: new Set(remote_hash_list.hashes)
};
}
return {
hash_set: new Set()
};
}
async function update_hash_list(application_uid, assetsMap) {
const cacheKey = await getCacheKey(application_uid);
const local_hash_list = await getAppHashCache(cacheKey);
const hashes = Object.keys(assetsMap);
const new_hashes = new Set([
...local_hash_list?.hashes || [],
...hashes
]);
await setAppHashCache(cacheKey, {
hashes: Array.from(new_hashes).sort()
});
}
export { get_hash_list, update_hash_list };
//# sourceMappingURL=distributed-hash-control.mjs.map