Skip to content

fix: use shutil.move to handle cross-device file upload#281

Merged
gary-Shen merged 1 commit into
opendatalab:mainfrom
gaoJava:fix/cross-device-link-upload
Jun 8, 2026
Merged

fix: use shutil.move to handle cross-device file upload#281
gary-Shen merged 1 commit into
opendatalab:mainfrom
gaoJava:fix/cross-device-link-upload

Conversation

@gaoJava

@gaoJava gaoJava commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Base repository:opendatalab/labelU,base:main

Problem

When running LabelU in Docker with /tmp and the media directory
mounted on different devices, uploading files fails with:

[Errno 18] Invalid cross-device link: '/tmp/tmpxxx' -> '/root/.local/share/labelu/media/upload/...'

Root Cause

LocalStorage.save_file uses Path.replace() which calls os.rename()
under the hood. os.rename() cannot move files across different mount
points or devices.

Fix

Replace local_path.replace(target_path) with
shutil.move(str(local_path), str(target_path)).

shutil.move() gracefully falls back to copy+delete when moving
across devices, resolving the issue.

File Changed

labelu/internal/common/storage.py

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."
@gary-Shen gary-Shen merged commit 9733848 into opendatalab:main Jun 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants