Skip to content

Commit c01545f

Browse files
committed
refactor
- cargo fmt
1 parent 60290f1 commit c01545f

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

gix-archive/src/write.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ fn append_zip_entry<W: std::io::Write + std::io::Seek>(
168168
) -> Result<(), Error> {
169169
let path = add_prefix(entry.relative_path(), tree_prefix).into_owned();
170170
let unix_permissions = if entry.mode.is_executable() { 0o755 } else { 0o644 };
171-
171+
172172
match entry.mode.kind() {
173173
gix_object::tree::EntryKind::Blob | gix_object::tree::EntryKind::BlobExecutable => {
174174
use bstr::ByteSlice;
@@ -182,9 +182,9 @@ fn append_zip_entry<W: std::io::Write + std::io::Seek>(
182182
.compression_method(rawzip::CompressionMethod::Deflate)
183183
.last_modified(mtime)
184184
.unix_permissions(unix_permissions);
185-
185+
186186
let (mut zip_entry, config) = file_builder.start().map_err(std::io::Error::other)?;
187-
187+
188188
// Use flate2 for compression. Level 9 is the maximum compression level for deflate.
189189
let encoder = flate2::write::DeflateEncoder::new(
190190
&mut zip_entry,
@@ -202,26 +202,29 @@ fn append_zip_entry<W: std::io::Write + std::io::Seek>(
202202
gix_object::tree::EntryKind::Tree | gix_object::tree::EntryKind::Commit => {
203203
use bstr::ByteSlice;
204204
// rawzip requires directory paths to end with '/'
205-
let mut dir_path = path.to_str().map_err(|_| {
206-
Error::Io(std::io::Error::new(
207-
std::io::ErrorKind::InvalidData,
208-
"Invalid UTF-8 in directory path",
209-
))
210-
})?.to_string();
205+
let mut dir_path = path
206+
.to_str()
207+
.map_err(|_| {
208+
Error::Io(std::io::Error::new(
209+
std::io::ErrorKind::InvalidData,
210+
"Invalid UTF-8 in directory path",
211+
))
212+
})?
213+
.to_string();
211214
if !dir_path.ends_with('/') {
212215
dir_path.push('/');
213216
}
214217
ar.new_dir(&dir_path)
215-
.last_modified(mtime)
216-
.unix_permissions(unix_permissions)
217-
.create()
218-
.map_err(std::io::Error::other)?;
218+
.last_modified(mtime)
219+
.unix_permissions(unix_permissions)
220+
.create()
221+
.map_err(std::io::Error::other)?;
219222
}
220223
gix_object::tree::EntryKind::Link => {
221224
use bstr::ByteSlice;
222225
buf.clear();
223226
std::io::copy(&mut entry, buf)?;
224-
227+
225228
// For symlinks, we need to create a file with symlink permissions
226229
let symlink_path = path.to_str().map_err(|_| {
227230
Error::Io(std::io::Error::new(
@@ -235,15 +238,15 @@ fn append_zip_entry<W: std::io::Write + std::io::Seek>(
235238
"Invalid UTF-8 in symlink target",
236239
))
237240
})?;
238-
241+
239242
let (mut zip_entry, config) = ar
240243
.new_file(symlink_path)
241244
.compression_method(rawzip::CompressionMethod::Store)
242245
.last_modified(mtime)
243246
.unix_permissions(0o120644) // Symlink mode
244247
.start()
245248
.map_err(std::io::Error::other)?;
246-
249+
247250
let mut writer = config.wrap(&mut zip_entry);
248251
writer.write_all(target.as_bytes())?;
249252
let (_, descriptor) = writer.finish().map_err(std::io::Error::other)?;

gix-archive/tests/archive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ mod from_tree {
194194
"prefix/symlink-to-a"
195195
]
196196
);
197-
197+
198198
// Find the symlink entry
199199
let ar = rawzip::ZipArchive::from_slice(buf.as_slice())?;
200200
let mut found_link = false;

0 commit comments

Comments
 (0)