| 2169 | } |
| 2170 | |
| 2171 | fn upload_archive_entries(source: UploadSource) -> Vec<UploadArchiveEntry> { |
| 2172 | let mut bytes = Vec::new(); |
| 2173 | write_upload_archive(&mut bytes, source).expect("write upload archive"); |
| 2174 | let mut archive = tar::Archive::new(std::io::Cursor::new(bytes)); |
| 2175 | let entries = archive.entries().expect("read archive entries"); |
| 2176 | let mut entries = entries |
| 2177 | .map(|entry| { |
| 2178 | let entry = entry.expect("read archive entry"); |
| 2179 | let path = entry |
| 2180 | .path() |
| 2181 | .expect("read archive path") |
| 2182 | .to_string_lossy() |
| 2183 | .into_owned(); |
| 2184 | let entry_type = entry.header().entry_type(); |
| 2185 | let link_name = entry |
| 2186 | .link_name() |
| 2187 | .expect("read archive link") |
| 2188 | .map(|link| link.to_string_lossy().into_owned()); |
| 2189 | |
| 2190 | UploadArchiveEntry { |
| 2191 | path, |
| 2192 | entry_type, |
| 2193 | link_name, |
| 2194 | } |
| 2195 | }) |
| 2196 | .collect::<Vec<_>>(); |
| 2197 | entries.sort_by(|left, right| left.path.cmp(&right.path)); |
| 2198 | entries |
| 2199 | } |
| 2200 | |
| 2201 | fn upload_archive_paths(source: UploadSource) -> Vec<String> { |
| 2202 | let mut paths = upload_archive_entries(source) |