mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
finish watch_service.py
This commit is contained in:
@@ -2,14 +2,14 @@
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Dict, Sequence
|
||||
from typing import Dict, Sequence, Optional
|
||||
|
||||
from loguru import logger
|
||||
|
||||
from basic_memory.file_utils import compute_checksum
|
||||
from basic_memory.models import Entity
|
||||
from basic_memory.repository.entity_repository import EntityRepository
|
||||
from basic_memory.sync.utils import SyncReport
|
||||
from basic_memory.sync.utils import SyncReport, FileChange
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -87,13 +87,19 @@ class FileChangeScanner:
|
||||
return result
|
||||
|
||||
async def find_changes(
|
||||
self, directory: Path, db_file_state: Dict[str, FileState]
|
||||
self,
|
||||
db_file_state: Dict[str, FileState],
|
||||
directory: Optional[Path] = None,
|
||||
) -> SyncReport:
|
||||
"""Find changes between filesystem and database."""
|
||||
# Get current files and checksums
|
||||
scan_result = await self.scan_directory(directory)
|
||||
current_files = scan_result.files
|
||||
|
||||
# scan the directory provided
|
||||
scan_result = await self.scan_directory(directory)
|
||||
|
||||
# the set of all of the current files and their checksums
|
||||
current_files = scan_result.files
|
||||
|
||||
# Build report
|
||||
report = SyncReport()
|
||||
|
||||
@@ -157,5 +163,6 @@ class FileChangeScanner:
|
||||
|
||||
async def find_knowledge_changes(self, directory: Path) -> SyncReport:
|
||||
"""Find changes in knowledge directory."""
|
||||
|
||||
db_file_state = await self.get_db_file_state(await self.entity_repository.find_all())
|
||||
return await self.find_changes(directory=directory, db_file_state=db_file_state)
|
||||
|
||||
Reference in New Issue
Block a user