mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	specially handle Buffer objects into Base64 and back for Becca
This commit is contained in:
		
							parent
							
								
									67766e3e9f
								
							
						
					
					
						commit
						6bb4bbb1af
					
				@ -364,6 +364,15 @@ function getEntityChangeRow(entityChange: EntityChange) {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Special handling for note_embeddings embedding field
 | 
			
		||||
        if (entityName === "note_embeddings") {
 | 
			
		||||
            // Cast to any to access the embedding property
 | 
			
		||||
            const row = entityRow as any;
 | 
			
		||||
            if (row.embedding && Buffer.isBuffer(row.embedding)) {
 | 
			
		||||
                row.embedding = row.embedding.toString("base64");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return entityRow;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -174,6 +174,11 @@ function updateNoteEmbedding(remoteEC: EntityChange, remoteEntityRow: EntityRow
 | 
			
		||||
    // Cast remoteEntityRow to include required embedding properties
 | 
			
		||||
    const typedRemoteEntityRow = remoteEntityRow as unknown as NoteEmbeddingRow;
 | 
			
		||||
 | 
			
		||||
    // Convert embedding from base64 string to Buffer if needed
 | 
			
		||||
    if (typedRemoteEntityRow.embedding && typeof typedRemoteEntityRow.embedding === "string") {
 | 
			
		||||
        typedRemoteEntityRow.embedding = Buffer.from(typedRemoteEntityRow.embedding, "base64");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const localEntityRow = sql.getRow<NoteEmbeddingRow>(`SELECT * FROM note_embeddings WHERE embedId = ?`, [remoteEC.entityId]);
 | 
			
		||||
 | 
			
		||||
    if (localEntityRow) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user