file_sync.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. """Shared file sync manager for remote execution backends.
  2. Tracks local file changes via mtime+size, detects deletions, and syncs to
  3. remote environments transactionally. Used by SSH, Modal, and Daytona.
  4. Docker uses bind mounts (live host FS view) and doesn't need this.
  5. """
  6. import hashlib
  7. import logging
  8. import os
  9. import posixpath
  10. import shlex
  11. import shutil
  12. import signal
  13. import tarfile
  14. import tempfile
  15. import threading
  16. import time
  17. try:
  18. import fcntl
  19. except ImportError:
  20. fcntl = None # Windows — file locking skipped
  21. from pathlib import Path
  22. from typing import Callable
  23. import psutil
  24. from hermes_constants import get_hermes_home
  25. from tools.environments.base import _file_mtime_key
  26. from utils import mtime_is_racy
  27. logger = logging.getLogger(__name__)
  28. # Tests patch these module-level aliases instead of ``time.sleep`` /
  29. # ``time.monotonic``: patching attributes on the shared ``time`` module object
  30. # leaks into unrelated threads when tests share a process and inflates retry
  31. # call counts.
  32. _sleep = time.sleep
  33. _monotonic = time.monotonic
  34. _SYNC_INTERVAL_SECONDS = 5.0
  35. _FORCE_SYNC_ENV = "HERMES_FORCE_FILE_SYNC"
  36. # Synced-state key no stat result equals (see _plan_sync): forces a content check next sync.
  37. _RACY_SYNC_KEY = (-1, -1, -1, -1)
  38. # Transport callbacks provided by each backend
  39. UploadFn = Callable[[str, str], None] # (host_path, remote_path) -> raises on failure
  40. BulkUploadFn = Callable[[list[tuple[str, str]]], None] # [(host_path, remote_path), ...] -> raises on failure
  41. BulkDownloadFn = Callable[[Path], None] # (dest_tar_path) -> writes tar archive, raises on failure
  42. DeleteFn = Callable[[list[str]], None] # (remote_paths) -> raises on failure
  43. GetFilesFn = Callable[[], list[tuple[str, str]]] # () -> [(host_path, remote_path), ...]
  44. _SYNC_BACK_MAX_RETRIES = 3
  45. _SYNC_BACK_BACKOFF = (2, 4, 8) # seconds between retries
  46. _SYNC_BACK_MAX_BYTES = 2 * 1024 * 1024 * 1024 # 2 GiB — refuse to extract larger tars
  47. _SYNC_BACK_MAX_BYTES_KEY = "sync_back_max_bytes" # config.yaml terminal.<key>
  48. _SYNC_BACK_TEMP_PREFIX = "hermes-sync-back-"
  49. # A sync-back temp entry (the downloaded tar or the extraction staging dir) is only leaked by
  50. # a hard kill (SIGKILL/OOM/power loss — the ``finally`` never runs). Entry names embed the
  51. # owning PID, so a dead owner's entry is reclaimed at once; the age cutoff covers the rest
  52. # (live or recycled PIDs, pre-ownership names, Windows where a PID cannot be probed). The
  53. # download is bounded by a 120 s subprocess timeout, so a live transfer is minutes old at
  54. # most; the old 6 h window let a crash loop pile up tens of GB before anything was reclaimed.
  55. _SYNC_BACK_STALE_SECONDS = 30 * 60
  56. def _sync_back_max_bytes() -> int:
  57. """Extraction cap; config.yaml ``terminal.sync_back_max_bytes`` overrides it for trees that
  58. legitimately exceed 2 GiB (a skipped extraction silently discards the whole download)."""
  59. from hermes_cli.config import load_config
  60. raw = ((load_config() or {}).get("terminal") or {}).get(_SYNC_BACK_MAX_BYTES_KEY)
  61. if raw is not None:
  62. try:
  63. return int(raw)
  64. except (TypeError, ValueError):
  65. logger.warning("sync_back: ignoring non-integer terminal.%s=%r", _SYNC_BACK_MAX_BYTES_KEY, raw)
  66. return _SYNC_BACK_MAX_BYTES
  67. def _sync_back_temp_prefix() -> str:
  68. """Temp prefix embedding the owning PID so the stale sweep can tell a hard-killed
  69. process's leftovers from another live gateway's in-flight transfer without guessing
  70. from mtime (a staging dir's mtime does not move while content streams into it)."""
  71. return f"{_SYNC_BACK_TEMP_PREFIX}{os.getpid()}-"
  72. def _temp_entry_owner_alive(name: str) -> bool:
  73. """Whether the process that created a sync-back temp entry may still be running.
  74. Names without a PID count as alive: the age cutoff applies."""
  75. pid_part = name[len(_SYNC_BACK_TEMP_PREFIX):].split("-", 1)[0]
  76. if not pid_part.isdigit():
  77. return True
  78. return psutil.pid_exists(int(pid_part))
  79. def _cleanup_stale_sync_back_temp(temp_dir: Path | None = None) -> int:
  80. """Remove sync-back tars and staging dirs left behind by a hard-killed process.
  81. Only entries carrying this module's prefix are touched: at once when their owner PID
  82. is dead, otherwise only past ``_SYNC_BACK_STALE_SECONDS``. Returns the number of
  83. entries removed; a permission error or a race with another sync-back must not prevent
  84. the current one.
  85. """
  86. directory = temp_dir or Path(tempfile.gettempdir())
  87. cutoff = time.time() - _SYNC_BACK_STALE_SECONDS
  88. removed = 0
  89. try:
  90. candidates = list(directory.glob(f"{_SYNC_BACK_TEMP_PREFIX}*"))
  91. except OSError:
  92. logger.debug("sync_back: could not scan temporary directory %s", directory)
  93. return 0
  94. for candidate in candidates:
  95. try:
  96. if candidate.is_symlink():
  97. continue
  98. if _temp_entry_owner_alive(candidate.name) and candidate.lstat().st_mtime >= cutoff:
  99. continue
  100. if candidate.is_dir():
  101. shutil.rmtree(candidate)
  102. else:
  103. candidate.unlink()
  104. removed += 1
  105. logger.debug("sync_back: removed stale temporary entry %s", candidate)
  106. except OSError:
  107. logger.debug("sync_back: could not remove stale temporary entry %s", candidate)
  108. return removed
  109. def iter_sync_files(container_base: str = "/root/.hermes") -> list[tuple[str, str]]:
  110. """Enumerate all (host_path, remote_path) pairs to sync to a remote. Credential paths are
  111. remapped from the hardcoded /root/.hermes to *container_base* (remote home may differ)."""
  112. # Late import: credential_files pulls in agent modules (circular at module level).
  113. from tools.credential_files import get_credential_file_mounts, iter_cache_files, iter_skills_files
  114. files = [
  115. (entry["host_path"], entry["container_path"].replace("/root/.hermes", container_base, 1))
  116. for entry in get_credential_file_mounts()]
  117. files += [
  118. (entry["host_path"], entry["container_path"])
  119. for entry in (*iter_skills_files(container_base=container_base),
  120. *iter_cache_files(container_base=container_base))]
  121. return files
  122. def _resolve_host_path_str(host_path: str) -> str:
  123. """Canonical string form of a host path (``resolve()`` falling back to ``expanduser()``)."""
  124. try:
  125. return str(Path(host_path).expanduser().resolve())
  126. except OSError:
  127. return str(Path(host_path).expanduser())
  128. def _credential_host_paths() -> set[str]:
  129. """Return credential files that are upload-only for remote sandboxes."""
  130. try:
  131. from tools.credential_files import get_credential_file_mounts
  132. mounts = get_credential_file_mounts()
  133. except Exception:
  134. return set()
  135. return {
  136. _resolve_host_path_str(entry["host_path"])
  137. for entry in mounts if isinstance(entry, dict) and entry.get("host_path")}
  138. def quoted_rm_command(remote_paths: list[str]) -> str:
  139. """Build a shell ``rm -f`` command for a batch of remote paths."""
  140. return "rm -f " + " ".join(shlex.quote(p) for p in remote_paths)
  141. def quoted_mkdir_command(dirs: list[str]) -> str:
  142. """Build a shell ``mkdir -p`` command for a batch of directories."""
  143. return "mkdir -p " + " ".join(shlex.quote(d) for d in dirs)
  144. def unique_parent_dirs(files: list[tuple[str, str]]) -> list[str]:
  145. """Extract sorted unique parent directories from (host, remote) pairs."""
  146. return sorted({posixpath.dirname(remote) for _, remote in files})
  147. def _sha256_file(path: str) -> str:
  148. """Return hex SHA-256 digest of a file."""
  149. h = hashlib.sha256()
  150. with open(path, "rb") as f:
  151. for chunk in iter(lambda: f.read(65536), b""):
  152. h.update(chunk)
  153. return h.hexdigest()
  154. class FileSyncManager:
  155. """Tracks local file changes and syncs to a remote environment. Backends supply transport
  156. callbacks (upload, delete) and a file-source callable; the manager handles mtime-based
  157. change detection, deletion tracking, rate limiting, and transactional state."""
  158. def __init__(
  159. self,
  160. get_files_fn: GetFilesFn,
  161. upload_fn: UploadFn,
  162. delete_fn: DeleteFn,
  163. sync_interval: float = _SYNC_INTERVAL_SECONDS,
  164. bulk_upload_fn: BulkUploadFn | None = None,
  165. bulk_download_fn: BulkDownloadFn | None = None):
  166. self._get_files_fn = get_files_fn
  167. self._upload_fn = upload_fn
  168. self._bulk_upload_fn = bulk_upload_fn
  169. self._bulk_download_fn = bulk_download_fn
  170. self._delete_fn = delete_fn
  171. self._transaction_lock = threading.Lock()
  172. self._synced_files: dict[str, tuple[int, int, int, int]] = {} # remote_path -> file_signature
  173. self._pushed_hashes: dict[str, str] = {} # remote_path -> sha256 hex digest
  174. self._upload_only_host_paths: set[str] = set()
  175. self._last_sync_time: float = 0.0 # monotonic; 0 ensures first sync runs
  176. self._sync_interval = sync_interval
  177. def sync(self, *, force: bool = False) -> None:
  178. """Run a sync cycle: upload changed files, delete removed files. Rate-limited to once
  179. per ``sync_interval`` unless *force* or ``HERMES_FORCE_FILE_SYNC=1``. Transactional:
  180. state is committed only if ALL operations succeed; on failure it rolls back so the
  181. next cycle retries everything."""
  182. with self._transaction_lock:
  183. self._sync_transaction(force=force)
  184. def _sync_transaction(self, *, force: bool = False) -> None:
  185. """Execute one sync cycle while holding the per-manager lock."""
  186. if (
  187. not force
  188. and not os.environ.get(_FORCE_SYNC_ENV)
  189. and _monotonic() - self._last_sync_time < self._sync_interval):
  190. return
  191. current_files = self._get_files_fn()
  192. self._upload_only_host_paths.update(_credential_host_paths())
  193. prev_files = dict(self._synced_files)
  194. prev_hashes = dict(self._pushed_hashes)
  195. try:
  196. # Planning reads files too (content check against the pushed hash): a file removed
  197. # or unreadable after its stat fails the cycle here like a staging read, so the
  198. # caller's command still runs and the next cycle retries.
  199. to_upload, new_files, to_delete = self._plan_sync(current_files)
  200. if not to_upload and not to_delete:
  201. self._synced_files = new_files # content-confirmed keys, nothing to push
  202. self._last_sync_time = _monotonic()
  203. return
  204. # Hash and upload the same bytes: the original may be saved while
  205. # the transport is reading it or waiting for remote acknowledgement.
  206. with tempfile.TemporaryDirectory(prefix="hermes-sync-push-") as staging:
  207. staged_files = []
  208. pushed_hashes = {}
  209. for index, (host_path, remote_path) in enumerate(to_upload):
  210. staged_path = os.path.join(staging, str(index))
  211. shutil.copy2(host_path, staged_path)
  212. pushed_hashes[remote_path] = _sha256_file(staged_path)
  213. staged_files.append((staged_path, remote_path))
  214. self._push(staged_files, to_delete)
  215. # Commit (all succeeded).
  216. self._pushed_hashes.update(pushed_hashes)
  217. for p in to_delete:
  218. new_files.pop(p, None)
  219. self._pushed_hashes.pop(p, None)
  220. self._synced_files = new_files
  221. self._last_sync_time = _monotonic()
  222. except Exception as exc:
  223. self._synced_files = prev_files
  224. self._pushed_hashes = prev_hashes
  225. # Do NOT advance _last_sync_time: bumping the rate-limit clock on failure would
  226. # suppress the retry for up to _sync_interval, contradicting the retry contract.
  227. logger.warning("file_sync: sync failed, rolled back state: %s", exc)
  228. def _plan_sync(
  229. self, current_files: list[tuple[str, str]]
  230. ) -> tuple[list[tuple[str, str]], dict[str, tuple[int, int, int, int]], list[str]]:
  231. """Diff *current_files* against synced state -> ``(to_upload, new_synced_state, to_delete)``."""
  232. to_upload: list[tuple[str, str]] = []
  233. new_files = dict(self._synced_files)
  234. for host_path, remote_path in current_files:
  235. file_key = _file_mtime_key(host_path)
  236. if file_key is None or self._synced_files.get(remote_path) == file_key:
  237. continue
  238. # A key whose mtime is still inside the racy window is recorded as never-matching: a
  239. # same-size rewrite in the same coarse tick would keep every stat field (ctime ticks
  240. # just as coarsely). The next sync then confirms the bytes against the pushed hash.
  241. recorded_key = _RACY_SYNC_KEY if mtime_is_racy(file_key[0]) else file_key
  242. new_files[remote_path] = recorded_key
  243. pushed_hash = self._pushed_hashes.get(remote_path)
  244. if pushed_hash is not None and _sha256_file(host_path) == pushed_hash:
  245. continue # the remote already holds these bytes
  246. to_upload.append((host_path, remote_path))
  247. current_remote_paths = {remote for _, remote in current_files}
  248. to_delete = [p for p in self._synced_files if p not in current_remote_paths]
  249. return to_upload, new_files, to_delete
  250. def _push(self, to_upload: list[tuple[str, str]], to_delete: list[str]) -> None:
  251. """Run the transport calls for one cycle (bulk upload when available)."""
  252. if to_upload:
  253. logger.debug("file_sync: uploading %d file(s)", len(to_upload))
  254. if to_delete:
  255. logger.debug("file_sync: deleting %d stale remote file(s)", len(to_delete))
  256. if to_upload and self._bulk_upload_fn is not None:
  257. self._bulk_upload_fn(to_upload)
  258. logger.debug("file_sync: bulk-uploaded %d file(s)", len(to_upload))
  259. else:
  260. for host_path, remote_path in to_upload:
  261. self._upload_fn(host_path, remote_path)
  262. logger.debug("file_sync: uploaded %s -> %s", host_path, remote_path)
  263. if to_delete:
  264. self._delete_fn(to_delete)
  265. logger.debug("file_sync: deleted %s", to_delete)
  266. # --- Sync-back: pull remote changes to host on teardown ---
  267. def sync_back(self, hermes_home: Path | None = None) -> None:
  268. """Pull remote changes back to the host: download the remote ``.hermes/`` as a tar and
  269. apply only files whose SHA-256 differs from what was pushed. SIGINT is deferred until
  270. complete; concurrent gateway sandboxes are serialized via a file lock."""
  271. with self._transaction_lock:
  272. self._sync_back_transaction(hermes_home=hermes_home)
  273. def _sync_back_transaction(self, hermes_home: Path | None = None) -> None:
  274. """Execute sync-back (with retries) against a stable snapshot of manager state."""
  275. if self._bulk_download_fn is None:
  276. return
  277. # Nothing was ever committed (initial push failed or never ran): skip
  278. # to avoid retry storms against an uninitialized remote .hermes/.
  279. if not self._pushed_hashes and not self._synced_files:
  280. logger.debug("sync_back: no prior push state — skipping")
  281. return
  282. lock_path = (hermes_home or get_hermes_home()) / ".sync.lock"
  283. lock_path.parent.mkdir(parents=True, exist_ok=True)
  284. last_exc: Exception | None = None
  285. for attempt in range(_SYNC_BACK_MAX_RETRIES):
  286. try:
  287. self._sync_back_once(lock_path)
  288. return
  289. except Exception as exc:
  290. last_exc = exc
  291. if attempt < _SYNC_BACK_MAX_RETRIES - 1:
  292. delay = _SYNC_BACK_BACKOFF[attempt]
  293. logger.warning("sync_back: attempt %d failed (%s), retrying in %ds", attempt + 1, exc, delay)
  294. _sleep(delay)
  295. logger.warning("sync_back: all %d attempts failed: %s", _SYNC_BACK_MAX_RETRIES, last_exc)
  296. def _sync_back_once(self, lock_path: Path) -> None:
  297. """Single sync-back attempt with SIGINT protection and file lock."""
  298. # signal.signal() only works from the main thread; gateway cleanup()
  299. # may run from a worker thread — skip SIGINT deferral there.
  300. on_main_thread = threading.current_thread() is threading.main_thread()
  301. deferred_sigint: list[object] = []
  302. original_handler = None
  303. if on_main_thread:
  304. original_handler = signal.getsignal(signal.SIGINT)
  305. def _defer_sigint(signum, frame):
  306. deferred_sigint.append((signum, frame))
  307. logger.debug("sync_back: SIGINT deferred until sync completes")
  308. signal.signal(signal.SIGINT, _defer_sigint)
  309. try:
  310. self._sync_back_locked(lock_path)
  311. finally:
  312. if on_main_thread and original_handler is not None:
  313. signal.signal(signal.SIGINT, original_handler)
  314. if deferred_sigint:
  315. # Re-deliver the deferred Ctrl+C to the restored handler. ``os.kill(os.getpid(),
  316. # SIGINT)`` is NOT graceful on Windows (routes to TerminateProcess, hard-killing
  317. # the CLI); ``raise_signal`` invokes the handler everywhere.
  318. signal.raise_signal(signal.SIGINT)
  319. def _sync_back_locked(self, lock_path: Path) -> None:
  320. """Sync-back under file lock (serializes concurrent gateways)."""
  321. if fcntl is None:
  322. # Windows: no flock — run without serialization
  323. self._sync_back_impl()
  324. return
  325. lock_fd = open(lock_path, "w", encoding="utf-8")
  326. try:
  327. fcntl.flock(lock_fd, fcntl.LOCK_EX)
  328. self._sync_back_impl()
  329. finally:
  330. try:
  331. fcntl.flock(lock_fd, fcntl.LOCK_UN)
  332. except OSError:
  333. pass
  334. lock_fd.close()
  335. def _sync_back_impl(self) -> None:
  336. """Download, diff, and apply remote changes to host."""
  337. if self._bulk_download_fn is None:
  338. raise RuntimeError("_sync_back_impl called without bulk_download_fn")
  339. # Cache file mapping once to avoid O(n*m) from repeated iteration
  340. try:
  341. file_mapping = list(self._get_files_fn())
  342. except Exception:
  343. file_mapping = []
  344. # A hard kill bypasses the finally below. Reclaim only old entries carrying our
  345. # prefix before allocating another full-tree download.
  346. _cleanup_stale_sync_back_temp()
  347. # mkstemp + close: NamedTemporaryFile keeps an exclusive handle on Windows, so the
  348. # backend's open(dest, "wb") / write_bytes on the same path raised PermissionError.
  349. fd, tar_path = tempfile.mkstemp(prefix=_sync_back_temp_prefix(), suffix=".tar")
  350. os.close(fd)
  351. try:
  352. self._bulk_download_fn(Path(tar_path))
  353. # A misbehaving sandbox could produce an arbitrarily large tar.
  354. try:
  355. tar_size = os.path.getsize(tar_path)
  356. except OSError:
  357. tar_size = 0
  358. max_bytes = _sync_back_max_bytes()
  359. if tar_size > max_bytes:
  360. logger.warning(
  361. "sync_back: remote tar is %d bytes (cap %d, override with terminal.%s) — skipping extraction",
  362. tar_size, max_bytes, _SYNC_BACK_MAX_BYTES_KEY)
  363. return
  364. with tempfile.TemporaryDirectory(prefix=_sync_back_temp_prefix()) as staging:
  365. with tarfile.open(tar_path) as tar:
  366. tar.extractall(staging, filter="data")
  367. upload_only = self._upload_only_host_paths | _credential_host_paths()
  368. applied = 0
  369. for dirpath, _dirnames, filenames in os.walk(staging):
  370. for fname in filenames:
  371. staged_file = os.path.join(dirpath, fname)
  372. # Remote keys are POSIX; relpath uses host separators (backslashes on Windows).
  373. remote_path = "/" + Path(os.path.relpath(staged_file, staging)).as_posix()
  374. applied += self._apply_staged_file(staged_file, remote_path, file_mapping, upload_only)
  375. if applied:
  376. logger.info("sync_back: applied %d changed file(s)", applied)
  377. else:
  378. logger.debug("sync_back: no remote changes detected")
  379. finally:
  380. try:
  381. os.unlink(tar_path)
  382. except OSError:
  383. pass
  384. def _apply_staged_file(
  385. self, staged_file: str, remote_path: str, file_mapping: list[tuple[str, str]], upload_only_host_paths: set[str],
  386. ) -> int:
  387. """Copy one extracted remote file onto the host if it changed since push. Returns 1 if
  388. applied, 0 if skipped (unchanged, unmapped, or an upload-only credential). A host file
  389. modified since push is overwritten with the remote version (last-write-wins) with a warning."""
  390. pushed_hash = self._pushed_hashes.get(remote_path)
  391. if pushed_hash is not None and _sha256_file(staged_file) == pushed_hash:
  392. return 0 # unchanged from push
  393. host_path = self._resolve_host_path(remote_path, file_mapping)
  394. if host_path is None:
  395. host_path = self._infer_host_path(remote_path, file_mapping, upload_only_host_paths=upload_only_host_paths)
  396. if host_path is None:
  397. logger.debug("sync_back: skipping %s (no host mapping)", remote_path)
  398. return 0
  399. if self._is_upload_only_host_path(host_path, upload_only_host_paths):
  400. logger.debug("sync_back: skipping upload-only credential file %s", remote_path)
  401. return 0
  402. if pushed_hash is not None and os.path.exists(host_path) and _sha256_file(host_path) != pushed_hash:
  403. logger.warning(
  404. "sync_back: conflict on %s — host modified "
  405. "since push, remote also changed. Applying remote version (last-write-wins).",
  406. remote_path)
  407. os.makedirs(os.path.dirname(host_path), exist_ok=True)
  408. shutil.copy2(staged_file, host_path)
  409. return 1
  410. def _resolve_host_path(self, remote_path: str, file_mapping: list[tuple[str, str]] | None = None) -> str | None:
  411. """Find the host path for a known remote path from the file mapping."""
  412. return next((host for host, remote in file_mapping or [] if remote == remote_path), None)
  413. def _infer_host_path(self, remote_path: str, file_mapping: list[tuple[str, str]] | None = None, *,
  414. upload_only_host_paths: set[str] | None = None) -> str | None:
  415. """Infer a host path for a new remote file by matching path prefixes: an existing
  416. remote->host pair whose parent directory prefixes *remote_path* gets the same
  417. substitution (``/root/.hermes/skills/b.md`` -> ``~/.hermes/skills/b.md``)."""
  418. upload_only_host_paths = upload_only_host_paths or set()
  419. for host, remote in file_mapping or []:
  420. if self._is_upload_only_host_path(host, upload_only_host_paths):
  421. continue
  422. remote_dir = posixpath.dirname(remote) # remote paths are POSIX even on a Windows host
  423. if remote_path.startswith(remote_dir + "/"):
  424. return str(Path(host).parent / remote_path[len(remote_dir) + 1:])
  425. return None
  426. @staticmethod
  427. def _is_upload_only_host_path(host_path: str, upload_only_host_paths: set[str]) -> bool:
  428. return _resolve_host_path_str(host_path) in upload_only_host_paths