Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions openviking/storage/viking_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from pyagfs import AGFSClient

from openviking.storage.vikingdb_interface import VikingDBInterface
from openviking.utils.time_utils import format_simplified, get_current_timestamp
from openviking.utils.time_utils import format_simplified, get_current_timestamp, parse_iso_datetime
from openviking_cli.utils.logger import get_logger
from openviking_cli.utils.uri import VikingURI

Expand Down Expand Up @@ -327,7 +327,7 @@ async def _walk(current_path: str, current_rel: str):
"size": entry.get("size", 0),
"isDir": entry.get("isDir", False),
"modTime": format_simplified(
datetime.fromisoformat(entry.get("modTime", "")), now
parse_iso_datetime(entry.get("modTime", "")), now
),
}
if entry.get("isDir"):
Expand Down Expand Up @@ -1016,7 +1016,7 @@ async def _ls_agent(
"uri": str(VikingURI(uri).join(name)),
"size": entry.get("size", 0),
"isDir": entry.get("isDir", False),
"modTime": format_simplified(datetime.fromisoformat(raw_time), now),
"modTime": format_simplified(parse_iso_datetime(raw_time), now),
}
if entry.get("isDir"):
all_entries.append(new_entry)
Expand Down
5 changes: 4 additions & 1 deletion openviking/utils/resource_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,12 @@ async def process_resource(
# ============ Phase 1: Parse source (Parser generates L0/L1 and writes to temp) ============
try:
media_processor = self._get_media_processor()
# Use reason as instruction fallback so it influences L0/L1
# generation and improves search relevance as documented.
effective_instruction = instruction or reason
parse_result = await media_processor.process(
source=path,
instruction=instruction,
instruction=effective_instruction,
**kwargs,
)
result["source_path"] = parse_result.source_path or path
Expand Down
14 changes: 14 additions & 0 deletions openviking/utils/time_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import re
from datetime import datetime, timezone

# Matches fractional seconds with more than 6 digits (e.g. .1470042)
_EXCESS_FRAC_RE = re.compile(r"(\.\d{6})\d+")


def parse_iso_datetime(value: str) -> datetime:
"""Parse an ISO 8601 datetime string, tolerating >6-digit fractional seconds.

Windows may produce timestamps like ``2026-02-21T13:20:23.1470042+08:00``
where the fractional seconds exceed Python's 6-digit microsecond limit.
This helper truncates the excess digits before parsing.
"""
return datetime.fromisoformat(_EXCESS_FRAC_RE.sub(r"\1", value))


def format_iso8601(dt: datetime) -> str:
"""
Expand Down
Loading