This commit is contained in:
2025-11-30 20:50:00 +01:00
parent 972be8425a
commit aa68e0f291
3 changed files with 24 additions and 11 deletions

View File

@@ -23,7 +23,11 @@ def copy_to_volume(volume_name, source_dir, container_path="/data", image="busyb
if not os.path.isdir(source_dir):
raise ValueError(f"Source directory {source_dir} does not exist")
if not os.listdir(source_dir):
print("Folder is empty")
return 1
else:
print("Folder is not empty")
# Check if volume exists
try:
volume = client.volumes.get(volume_name)
@@ -36,6 +40,7 @@ def copy_to_volume(volume_name, source_dir, container_path="/data", image="busyb
print(f"Copying files from {source_dir} to volume '{volume_name}'...")
# Run temporary container to copy files
print(container_path)
client.containers.run(
image,
command=f"sh -c 'cp -r /tmp/* {container_path}/'",