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

Function removeNonExistentFiles

main.js:2584–2742  ·  view source on GitHub ↗
(scanDirectoryPath, window = null)

Source from the content-addressed store, hash-verified

2582 restartHttpServerNow().catch((error) => {
2583 console.error('Error during server restart:', error);
2584 });
2585 }, 100);
2586 return { success: true, message: 'Server restart initiated' };
2587}
2588
2589let db;
2590let mainWindow;
2591let isGeneratingHashes = false; // Track hash generation state
2592let isHashGenerationScheduled = false;
2593let isCompressingThumbnailsBackground = false;
2594const THUMBNAIL_MIGRATION_DELAY_MS = Math.max(
2595 15000,
2596 Number.parseInt(process.env.PRINTVENTORY_THUMBNAIL_MIGRATION_DELAY_MS || '30000', 10) || 30000
2597);
2598const THUMBNAIL_MIGRATION_MAX_PER_SESSION = Math.max(
2599 25,
2600 Number.parseInt(process.env.PRINTVENTORY_THUMBNAIL_MIGRATION_MAX_PER_SESSION || '200', 10) || 200
2601);
2602const THUMBNAIL_MIGRATION_YIELD_MS = 25;
2603
2604function scheduleBackgroundThumbnailCompression(reason) {
2605 setTimeout(() => {
2606 compressExistingThumbnailsInBackground(reason).catch((error) => {
2607 console.error('Background thumbnail compression failed:', error);
2608 });
2609 }, THUMBNAIL_MIGRATION_DELAY_MS);
2610}
2611
2612function getThumbnailStoredLength(filePath) {
2613 if (!db || !filePath) return 0;
2614 const row = db.prepare('SELECT LENGTH(thumbnail) AS len FROM models WHERE filePath = ?').get(filePath);
2615 return row?.len ?? 0;
2616}
2617
2618function clearThumbnailForPath(filePath, reason) {
2619 if (!db || !filePath) return false;
2620 try {
2621 const result = db.prepare('UPDATE models SET thumbnail = NULL WHERE filePath = ?').run(filePath);
2622 if (result.changes > 0) {
2623 console.warn(`Cleared thumbnail for ${filePath}${reason ? ` (${reason})` : ''}`);
2624 }
2625 return result.changes > 0;
2626 } catch (error) {
2627 console.error(`Failed to clear thumbnail for ${filePath}:`, error);
2628 return false;
2629 }
2630}
2631
2632function purgeCorruptThumbnailsOnly(maxChars = THUMBNAIL_ABSOLUTE_MAX_LOAD_CHARS) {
2633 if (!db) return 0;
2634 try {
2635 const result = db.prepare(`
2636 UPDATE models
2637 SET thumbnail = NULL
2638 WHERE thumbnail IS NOT NULL
2639 AND LENGTH(thumbnail) > ?
2640 `).run(maxChars);
2641 if (result.changes > 0) {

Callers 1

main.jsFile · 0.85

Calls 4

checkZipEntryExistsFunction · 0.85
parseZipPathFunction · 0.70
debugLogFunction · 0.70

Tested by

no test coverage detected