File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed
Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -241,13 +241,6 @@ fn normalize_directory(path: &Path) -> Result<TempFile> {
241241
242242 let mut file_count = 0 ;
243243
244- // Get the directory name to preserve in the zip structure
245- let dir_name = path
246- . file_name ( )
247- . ok_or_else ( || anyhow ! ( "Failed to get directory name" ) ) ?
248- . to_str ( )
249- . ok_or_else ( || anyhow ! ( "Directory name is not valid UTF-8" ) ) ?;
250-
251244 // Collect and sort entries for deterministic ordering
252245 // This is important to ensure stable sha1 checksums for the zip file as
253246 // an optimization is used to avoid re-uploading the same chunks if they're already on the server.
@@ -269,11 +262,12 @@ fn normalize_directory(path: &Path) -> Result<TempFile> {
269262 . last_modified_time ( DateTime :: default ( ) ) ;
270263
271264 for entry_path in entries {
272- let relative_path = entry_path. strip_prefix ( path) ?. to_owned ( ) ;
273- let full_relative_path = Path :: new ( dir_name) . join ( relative_path) ;
274- debug ! ( "Adding file to zip: {}" , full_relative_path. display( ) ) ;
265+ let zip_path = entry_path. strip_prefix (
266+ path. parent ( ) . ok_or_else ( || anyhow ! ( "Failed to get parent directory" ) ) ?
267+ ) ?. to_owned ( ) ;
268+ debug ! ( "Adding file to zip: {}" , zip_path. display( ) ) ;
275269
276- zip. start_file ( full_relative_path . to_string_lossy ( ) , options) ?;
270+ zip. start_file ( zip_path . to_string_lossy ( ) , options) ?;
277271 let file_byteview = ByteView :: open ( & entry_path) ?;
278272 zip. write_all ( file_byteview. as_slice ( ) ) ?;
279273 file_count += 1 ;
You can’t perform that action at this time.
0 commit comments