(writer: W, source: UploadSource)
| 603 | } |
| 604 | |
| 605 | fn write_upload_archive<W: Write>(writer: W, source: UploadSource) -> Result<()> { |
| 606 | let mut archive = tar::Builder::new(writer); |
| 607 | match source { |
| 608 | UploadSource::SinglePath { |
| 609 | local_path, |
| 610 | tar_name, |
| 611 | } => { |
| 612 | append_upload_path(&mut archive, &local_path, Path::new(&tar_name), false)?; |
| 613 | } |
| 614 | UploadSource::FileList { |
| 615 | base_dir, |
| 616 | files, |
| 617 | archive_prefix, |
| 618 | } => { |
| 619 | for file in &files { |
| 620 | let full_path = base_dir.join(file); |
| 621 | let archive_path = archive_prefix |
| 622 | .as_ref() |
| 623 | .map_or_else(|| PathBuf::from(file), |prefix| prefix.join(file)); |
| 624 | append_upload_path(&mut archive, &full_path, &archive_path, true)?; |
| 625 | } |
| 626 | } |
| 627 | } |
| 628 | archive.finish().into_diagnostic()?; |
| 629 | Ok(()) |
| 630 | } |
| 631 | |
| 632 | fn append_upload_path<W: Write>( |
| 633 | archive: &mut tar::Builder<W>, |
no test coverage detected