Skip to content

Commit 483d56a

Browse files
committed
bundles: fix "fetching" of 0-sized files
1 parent 5397e4e commit 483d56a

1 file changed

Lines changed: 28 additions & 23 deletions

File tree

crates/bundles/src/itar.rs

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -159,35 +159,40 @@ impl CacheBackend for IndexedTarBackend {
159159
let mut overall_failed = true;
160160
let mut any_failed = false;
161161

162-
for _ in 0..MAX_HTTP_ATTEMPTS {
163-
let mut stream = match self.reader.read_range(info.offset, n) {
164-
Ok(r) => r,
165-
Err(e) => {
166-
tt_warning!(status, "failure requesting \"{}\" from network", name; e);
162+
// Our HTTP implementation actually has problems with zero-sized ranged
163+
// reads (Azure gives us a 200 response, which we don't properly
164+
// handle), but when the file is 0-sized we're all set anyway!
165+
if n > 0 {
166+
for _ in 0..MAX_HTTP_ATTEMPTS {
167+
let mut stream = match self.reader.read_range(info.offset, n) {
168+
Ok(r) => r,
169+
Err(e) => {
170+
tt_warning!(status, "failure requesting \"{}\" from network", name; e);
171+
any_failed = true;
172+
continue;
173+
}
174+
};
175+
176+
if let Err(e) = stream.read_to_end(&mut buf) {
177+
tt_warning!(status, "failure downloading \"{}\" from network", name; e.into());
167178
any_failed = true;
168179
continue;
169180
}
170-
};
171181

172-
if let Err(e) = stream.read_to_end(&mut buf) {
173-
tt_warning!(status, "failure downloading \"{}\" from network", name; e.into());
174-
any_failed = true;
175-
continue;
182+
overall_failed = false;
183+
break;
176184
}
177185

178-
overall_failed = false;
179-
break;
180-
}
181-
182-
if overall_failed {
183-
bail!(
184-
"failed to retrieve \"{}\" from the network; \
185-
this most probably is not Tectonic's fault \
186-
-- please check your network connection.",
187-
name
188-
);
189-
} else if any_failed {
190-
tt_note!(status, "download succeeded after retry");
186+
if overall_failed {
187+
bail!(
188+
"failed to retrieve \"{}\" from the network; \
189+
this most probably is not Tectonic's fault \
190+
-- please check your network connection.",
191+
name
192+
);
193+
} else if any_failed {
194+
tt_note!(status, "download succeeded after retry");
195+
}
191196
}
192197

193198
Ok(buf)

0 commit comments

Comments
 (0)