mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	check if sync is configured every minute, not just at app startup, fixes #138
This commit is contained in:
		@@ -304,31 +304,20 @@ async function setLastSyncedPush(lastSyncedPush) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function updatePushStats() {
 | 
					async function updatePushStats() {
 | 
				
			||||||
 | 
					    if (await syncOptions.isSyncSetup()) {
 | 
				
			||||||
        const lastSyncedPush = await optionService.getOption('lastSyncedPush');
 | 
					        const lastSyncedPush = await optionService.getOption('lastSyncedPush');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        stats.outstandingPushes = await sql.getValue("SELECT COUNT(*) FROM sync WHERE id > ?", [lastSyncedPush]);
 | 
					        stats.outstandingPushes = await sql.getValue("SELECT COUNT(*) FROM sync WHERE id > ?", [lastSyncedPush]);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
sqlInit.dbReady.then(async () => {
 | 
					sqlInit.dbReady.then(async () => {
 | 
				
			||||||
    if (await syncOptions.isSyncSetup()) {
 | 
					 | 
				
			||||||
        log.info("Setting up sync to " + await syncOptions.getSyncServerHost() + " with timeout " + await syncOptions.getSyncTimeout());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        const syncProxy = await syncOptions.getSyncProxy();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (syncProxy) {
 | 
					 | 
				
			||||||
            log.info("Sync proxy: " + syncProxy);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    setInterval(cls.wrap(sync), 60000);
 | 
					    setInterval(cls.wrap(sync), 60000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // kickoff initial sync immediately
 | 
					    // kickoff initial sync immediately
 | 
				
			||||||
    setTimeout(cls.wrap(sync), 1000);
 | 
					    setTimeout(cls.wrap(sync), 1000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    setInterval(cls.wrap(updatePushStats), 1000);
 | 
					    setInterval(cls.wrap(updatePushStats), 1000);
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    else {
 | 
					 | 
				
			||||||
        log.info("Sync server not configured, sync timer not running.")
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = {
 | 
					module.exports = {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user