Commit fe199fb
[8.6.0] zipper: handle empty filelist (#28425)
updates the zipper utility so it can handle empty filelists. previously
this would fail with
```
File does not seem to exist.
```
(note the double space)
rather than being treated as an empty list (`[]`), an empty filelist was
being treated as a non-empty list of length one with the only element
being an empty string (`['']`)
---
Why on earth do I want this? I have a rule that outputs a zip file that
may or may not be empty. There is no easy way to tell ahead of time if
there will be files. The output *could* be optional, but that would make
my life harder for reasons that I can't be bothered explaining (feel
free to push on this if it's important).
`@bazel_tools//tools/zip:zipper` fails if the filelist is empty and I am
working around this by manually creating an empty zip file using the
EOCD record:
```js
if (files.length === 0) {
fs.writeFileSync(zipFile, '\x50\x4b\x05\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00');
}
```
it would be nice if I didn't have to do this :)
Closes #27008.
PiperOrigin-RevId: 812683346
Change-Id: Ifb7dc35b37ce9c07e53786206e90570da542fab7
Commit
349f6fb
Co-authored-by: Christian Scott <[email protected]>1 parent 06431b3 commit fe199fb
2 files changed
+13
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
214 | 221 | | |
215 | 222 | | |
216 | 223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
251 | 257 | | |
252 | 258 | | |
253 | 259 | | |
| |||
0 commit comments