const CONFIG = require('./config.js'); const Library = require('./library.js').Library; const Path = require('path'); function LibraryManager() { this.libraries = []; this.updating = false; for (let i of CONFIG.photoLibraries) this.push(i); } LibraryManager.prototype.push = function(path) { this.libraries.push(new Library(path)); } LibraryManager.prototype.updateLibraries = async function(dbHelper) { if (this.updating) return; this.updating = true; await Promise.allSettled(this.libraries.map(i => i.updateLibrary(dbHelper))); this.updating = false; } LibraryManager.prototype.isUpdating = function() { return this.updating; } LibraryManager.prototype.findMedia = async function(path) { path = Path.normalize(path); for (let i of this.libraries) { let media = await i.findMedia(path); if (media) return media; } return null; } module.exports.LibraryManager = new LibraryManager();