From f911bf2995f6754f865724ff168b200eed353339 Mon Sep 17 00:00:00 2001 From: gaojianda <15731133699@163.com> Date: Mon, 8 Jun 2026 11:23:49 +0800 Subject: [PATCH] Using Path.replace() calls os.rename() under the hood, which fails with [Errno 18] Invalid cross-device link when /tmp and the media directory are on different mount points (common in Docker environments). Replace with shutil.move() which gracefully falls back to copy+delete when moving across devices." --- labelu/internal/common/storage.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/labelu/internal/common/storage.py b/labelu/internal/common/storage.py index fe797c2c..4f1f0370 100644 --- a/labelu/internal/common/storage.py +++ b/labelu/internal/common/storage.py @@ -2,6 +2,7 @@ from abc import ABC, abstractmethod from functools import lru_cache +import shutil from pathlib import Path from typing import Optional @@ -60,7 +61,7 @@ def _resolve(self, key: str) -> Path: def save_file(self, local_path: Path, key: str, content_type: Optional[str] = None) -> None: target_path = self._resolve(key) target_path.parent.mkdir(parents=True, exist_ok=True) - local_path.replace(target_path) + shutil.move(str(local_path), str(target_path)) def save_bytes(self, content: bytes, key: str, content_type: Optional[str] = None) -> None: target_path = self._resolve(key)