This commit is contained in:
2025-04-05 11:21:58 +02:00
parent 88e4a2a4b1
commit e9a73327e3
5 changed files with 259 additions and 7 deletions

View File

@@ -34,7 +34,8 @@ impl ContentOperations {
// Copy the temporary file to the container
let temp_path = temp_file.path().to_string_lossy().to_string();
execute_buildah_command(&["copy", container_id, &temp_path, dest_path])
// Use add instead of copy for better handling of paths
execute_buildah_command(&["add", container_id, &temp_path, dest_path])
}
/// Read content from a file in the container
@@ -55,7 +56,18 @@ impl ContentOperations {
let temp_path = temp_file.path().to_string_lossy().to_string();
// Copy the file from the container to the temporary file
execute_buildah_command(&["copy", container_id, source_path, &temp_path])?;
// Use mount to access the container's filesystem
let mount_result = execute_buildah_command(&["mount", container_id])?;
let mount_point = mount_result.stdout.trim();
// Construct the full path to the file in the container
let full_source_path = format!("{}{}", mount_point, source_path);
// Copy the file from the mounted container to the temporary file
execute_buildah_command(&["copy", container_id, &full_source_path, &temp_path])?;
// Unmount the container
execute_buildah_command(&["umount", container_id])?;
// Read the content from the temporary file
let mut file = File::open(temp_file.path())