MCPcopy
hub / github.com/apify/crawlee / getLocalKeyValueStoreItems

Function getLocalKeyValueStoreItems

test/e2e/tools.mjs:377–405  ·  view source on GitHub ↗
(dirName, kvName)

Source from the content-addressed store, hash-verified

375 * @param {string} kvName
376 */
377export async function getLocalKeyValueStoreItems(dirName, kvName) {
378 const dir = getStorage(dirName);
379 const storePath = join(dir, 'key_value_stores', kvName);
380
381 if (!existsSync(storePath)) {
382 return undefined;
383 }
384
385 const dirents = await readdir(storePath, { withFileTypes: true });
386 const fileNames = dirents.filter((dirent) => dirent.isFile());
387 const keyValueStoreRecords = [];
388
389 for (const fileName of fileNames) {
390 if (fileName.name.includes('__metadata__')) continue;
391
392 const filePath = join(storePath, fileName.name);
393 const buffer = await readFile(filePath);
394
395 const name = fileName.name.split('.').slice(0, -1).join('.');
396
397 if (isPrivateEntry(name)) {
398 continue;
399 }
400
401 keyValueStoreRecords.push({ name, raw: buffer });
402 }
403
404 return keyValueStoreRecords;
405}
406
407/**
408 * @param {string} dirName

Callers 1

runActorFunction · 0.85

Calls 3

getStorageFunction · 0.85
isPrivateEntryFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…