Fix domain vault init check in finish_crawl/get_stats
- Add _initialized check to finish_crawl() and get_stats() in all 3 vault classes - Prevents FileNotFoundError when git commands run on non-existent directories - Update test_crawl.py to use pytest tmp_path fixture - Add network marker to skip functional tests in CI with '-m "not network"'
This commit is contained in:
parent
45e851aa15
commit
6193ce2724
3 changed files with 49 additions and 12 deletions
|
|
@ -372,6 +372,9 @@ class DomainHtmlVault:
|
|||
|
||||
async def finish_crawl(self, stats: Dict[str, Any]) -> Optional[str]:
|
||||
"""Finish crawl, log it, and commit if changes."""
|
||||
if not self._initialized:
|
||||
await self.init()
|
||||
|
||||
log = await self._load_crawl_log()
|
||||
log['crawls'].append({
|
||||
'timestamp': datetime.now(timezone.utc).isoformat(),
|
||||
|
|
@ -386,6 +389,9 @@ class DomainHtmlVault:
|
|||
|
||||
async def get_stats(self) -> Dict[str, Any]:
|
||||
"""Get vault statistics."""
|
||||
if not self._initialized:
|
||||
await self.init()
|
||||
|
||||
log = await self._load_crawl_log()
|
||||
commits = await self._git.log(5)
|
||||
|
||||
|
|
@ -510,6 +516,9 @@ class DomainMediaVault:
|
|||
|
||||
async def finish_crawl(self, stats: Dict[str, Any]) -> Optional[str]:
|
||||
"""Finish crawl and commit if changes."""
|
||||
if not self._initialized:
|
||||
await self.init()
|
||||
|
||||
media_new = stats.get('media_new', 0)
|
||||
if media_new > 0:
|
||||
return await self._git.commit(f"Crawl: {media_new} media files")
|
||||
|
|
@ -517,6 +526,9 @@ class DomainMediaVault:
|
|||
|
||||
async def get_stats(self) -> Dict[str, Any]:
|
||||
"""Get vault statistics."""
|
||||
if not self._initialized:
|
||||
await self.init()
|
||||
|
||||
index = await self._load_index()
|
||||
commits = await self._git.log(5)
|
||||
|
||||
|
|
@ -649,6 +661,9 @@ class DomainLinkpeekVault:
|
|||
|
||||
async def finish_crawl(self, stats: Dict[str, Any]) -> Optional[str]:
|
||||
"""Finish crawl and commit if changes."""
|
||||
if not self._initialized:
|
||||
await self.init()
|
||||
|
||||
screenshots_new = stats.get('screenshots_new', 0)
|
||||
if screenshots_new > 0:
|
||||
return await self._git.commit(f"Crawl: {screenshots_new} screenshots")
|
||||
|
|
@ -656,6 +671,9 @@ class DomainLinkpeekVault:
|
|||
|
||||
async def get_stats(self) -> Dict[str, Any]:
|
||||
"""Get vault statistics."""
|
||||
if not self._initialized:
|
||||
await self.init()
|
||||
|
||||
index = await self._load_index()
|
||||
commits = await self._git.log(5)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue