(files, reload = true)
| 1394 | } |
| 1395 | |
| 1396 | function 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, |
no test coverage detected