mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			30 lines
		
	
	
		
			663 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			663 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| const utils = require('./utils');
 | |
| const log = require('./log');
 | |
| const sql = require('./sql');
 | |
| 
 | |
| const currentSourceId = utils.randomString(12);
 | |
| 
 | |
| log.info("Using sourceId=" + currentSourceId);
 | |
| 
 | |
| let allSourceIds = [];
 | |
| 
 | |
| sql.dbReady.then(async () => {
 | |
|     try {
 | |
|         sql.insert("source_ids", {
 | |
|             source_id: currentSourceId,
 | |
|             date_created: utils.nowTimestamp()
 | |
|         });
 | |
| 
 | |
|         allSourceIds = await sql.getFlattenedResults("source_id", "SELECT source_id FROM source_ids");
 | |
|     }
 | |
|     catch (e) {}
 | |
| });
 | |
| 
 | |
| function isLocalSourceId(srcId) {
 | |
|     return allSourceIds.includes(srcId);
 | |
| }
 | |
| 
 | |
| module.exports = {
 | |
|     currentSourceId,
 | |
|     isLocalSourceId
 | |
| }; |