MCPcopy
hub / github.com/ollm/OpenComic / validateJson

Function validateJson

scripts/cache.js:429–506  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

427}
428
429function validateJson(name)
430{
431 if(zstd !== false)
432 {
433 const path = p.join(cacheFolder, name+'.zstd');
434
435 if(fs.existsSync(path))
436 {
437 let json;
438
439 try
440 {
441 json = fs.readFileSync(path);
442 }
443 catch
444 {
445 return 'readError';
446 }
447
448 try
449 {
450 json = zstdDecoder.decodeSync(json);
451 }
452 catch
453 {
454 return 'corruptedZstd';
455 }
456
457 try
458 {
459 JSON.parse(json);
460 }
461 catch
462 {
463 return 'corruptedJson';
464 }
465
466 return 'correct';
467 }
468 else
469 {
470 return 'notInCache';
471 }
472 }
473 else
474 {
475 const path = p.join(cacheFolder, name);
476
477 if(fs.existsSync(path))
478 {
479 let json;
480
481 try
482 {
483 json = fs.readFileSync(path);
484 }
485 catch
486 {

Callers 1

_validateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected