Closed deven96 closed 8 months ago
You need to seek the file back to the start after writing.
You're correct @the8472
Seek
isn't implemented for GzDecoder
and I tried Write::flush
maybe it would reset the cursor but to no avail
Can you try to open the decoded file after it was flushed, from disk? I have a feeling this is an issue related to the way GzDecoder
works, and I'd be a bit surprised if one can use it like it's done here.
My hypothesis is that the decoded data is written to disk, but that it's impossible to do so through GzDecoder
.
The .csv.gz
is actually on disk correctly i.e I can manually unzip and retrieve the original file after the first copy
(even without flush). However as I can't reset the cursor via GzDecoder
there's no way to tell it to return to start before starting the read
You can access the inner via get_mut
. Or you can operate on the File
directly and only wrap it in the encoder once it's written. It shouldn't be necessary to write through the encoder.
That's the implementation I eventually stuck with, writing to the file first and then operating after. Would it be possible however to do
use std::io::Seek
/// where there is an `impl <S: Seek> for GzDecoder<S>`
zip_buffer.rewind()?;
With usecase being that I want to [ write (compress to gz) -> read (uncompressed) ]
Although I can see that the Write
implementation expects already compressed data
Currently I have a snippet of code that's supposed to do a few things
.csv.gz
file in read-write mode usingstd::fs::OpenOptions
and pass that into a decoder.csv.gz
source into the decoder (std::io::Write
)std::io::Read
)In order to temporarily fix I rewrote directly to the new file and only after copying from remote source did I open the file in read mode with GzDecoder. I'm not quite certain if the issue would be from
OpenOptions
itself orGzDecoder