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

Function addComicsToLibrary

scripts/opencomic.js:1396–1473  ·  view source on GitHub ↗
(files, reload = true)

Source from the content-addressed store, hash-verified

1394}
1395
1396function addComicsToLibrary(files, reload = true)
1397{
1398 let added = false;
1399
1400 for(let i in files)
1401 {
1402 let filePath = files[i];
1403
1404 if(pathIsSupported(filePath))
1405 {
1406 let name, path, compressed;
1407
1408 if(fs.statSync(filePath).isDirectory())
1409 {
1410 name = p.basename(filePath);
1411 path = filePath;
1412 compressed = false;
1413 }
1414 else
1415 {
1416 if(compatible.image(filePath))
1417 {
1418 filePath = p.dirname(filePath);
1419
1420 name = p.basename(filePath);
1421 path = filePath;
1422 compressed = false;
1423 }
1424 else
1425 {
1426 name = p.basename(filePath).replace(/\.[^\.]*$/, '');
1427 path = filePath;
1428 compressed = true;
1429 }
1430 }
1431
1432 path = relative.path(path);
1433 let comics = storage.get('comics');
1434 let exists = false;
1435
1436 for(let key in comics)
1437 {
1438 if(comics[key].path == path)
1439 {
1440 exists = true;
1441
1442 break;
1443 }
1444 }
1445
1446 if(!exists)
1447 {
1448 storage.push('comics', {
1449 name: name,
1450 path: path,
1451 added: time(),
1452 compressed: compressed,
1453 folder: true,

Callers 3

downloadFunction · 0.85
addComicFunction · 0.85
handleDropFunction · 0.85

Calls 2

pathIsSupportedFunction · 0.85
timeFunction · 0.70

Tested by

no test coverage detected