MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / initializeDatabase

Function initializeDatabase

main.js:1600–1721  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1598 }
1599
1600 // Close HTTP server
1601 server.close(() => {
1602 console.log('HTTP server closed');
1603 if (httpServerEpoch === epoch) {
1604 httpServer = null;
1605 wsClients = null;
1606 global.broadcastEvent = null;
1607 global.sendEvent = null;
1608 }
1609 resolve();
1610 });
1611
1612 // Force close after timeout if graceful shutdown doesn't complete
1613 setTimeout(() => {
1614 if (httpServerEpoch !== epoch) return;
1615 if (httpServer === server) {
1616 console.log('Force closing HTTP server...');
1617 try {
1618 server.close();
1619 } catch (error) {
1620 console.error('Error force closing server:', error);
1621 }
1622 httpServer = null;
1623 wsClients = null;
1624 wss = null;
1625 global.broadcastEvent = null;
1626 global.sendEvent = null;
1627 resolve();
1628 }
1629 }, 5000);
1630 });
1631}
1632
1633function getSettingValueOr(key, fallback) {
1634 try {
1635 if (!db) return fallback;
1636 const row = db.prepare('SELECT value FROM settings WHERE key = ?').get(key);
1637 if (row && row.value != null && row.value !== '') return row.value;
1638 } catch (_) { /* ignore */ }
1639 return fallback;
1640}
1641
1642let extensionInboxTimer = null;
1643let extensionInboxImporting = false;
1644
1645function getExtensionInboxDirectory() {
1646 return extensionInbox.resolveInboxDirectory(getSettingValueOr('extensionInboxDirectory', ''));
1647}
1648
1649function getExtensionInboxDirectories() {
1650 const custom = (getSettingValueOr('extensionInboxDirectory', '') || '').trim();
1651 return extensionInbox.uniqueInboxDirectories([
1652 custom || null,
1653 extensionInbox.defaultInboxDirectory(),
1654 extensionInbox.inboxDirectoryBesideDatabase(getDatabasePath())
1655 ]);
1656}
1657

Callers 1

main.jsFile · 0.85

Calls 7

getDatabasePathFunction · 0.85
migrateDateAddedColumnFunction · 0.85
migrateIsNewColumnFunction · 0.85
repairModelTagsTableFunction · 0.85
ensureSlicersTableExistsFunction · 0.85

Tested by

no test coverage detected