On Mon, Jul 02, 2018 at 08:44:30PM +0200, Gandalf Corvotempesta wrote: > I'm trying to convert my simple bash script to a perl one (hoping > would be included in PVE), for directly convert a Xen VM to a PVE/KVM > on ZFS, in a single pass. > > I have one question: can someone tell me how to read a huge tar file > (from a pipe) and extract one file at once? > > Something like the following pseudocode: > > $myTarFile = TAR::read(my_http_stream) > foreach ( $myTarFile->extract() as $singleFIle ) { > doSomeThing($singleFile) > }
I'd recommend looking at libarchive's API (Archive::Libarchive), that should be capable of dealing with a stream. > > I can't read all files inside the tarball, because this would require > to download the whole file at first, > then read it's content and then read each file one by one. It's too > time consuming. Or you just extract the files while downloading by piping to tar/bsdtar. Also, seeing how this isn't a task you do 100 times a day every day, time shouldn't be that much of an issue. _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel