laktak / zfind

search for files (even inside tar/zip/7z/rar) using a SQL-WHERE filter
MIT License
381 stars 4 forks source link

Archive files may be getting opened even when "not archive" is set #5

Closed avioli closed 3 months ago

avioli commented 3 months ago

When I issue the following command:

$ zfind 'not archive and ext="foo"'

(Ignoring the following error) I am getting the impression an archive is opened, even when I've explicitly specified not archive:

error: web/core/tests/fixtures/config_install/testing_config_install_no_config.tar.gz: gzip: invalid header
web/modules/contrib/feeds/tests/resources/file.foo

The error is irrelevant, but here's the specific archive I stumbled upon in one of my Drupal projects (it has no files in it): testing_config_install_no_config.tar.gz

laktak commented 3 months ago

You are right. You probably took that from the README - I've updated it to explain it better.

Please use -n instead:

-n, --no-archive                Disables archive support.

I need to open the archive to evaluate the query. Even if I would treat it separately it's probably not worth it (e.g. it could be not archive or name="foo").

laktak commented 3 months ago

I'll also take a look at that archive.

laktak commented 3 months ago

I think the error for your archive is OK:

$ tar -tf testing_config_install_no_config.tar.gz

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
avioli commented 3 months ago

Thanks. I don't really care about the archive file itself being broken (or invalid gzip), since it was a side-effect - totally unexpected. It was the reason I realised your tool is opening archives by default, though.

NOTE: Using hexdump I can see that the file is purely filled with 1024 zeroes, so - sorry for your wasted time checking it.

$ hexdump web/core/tests/fixtures/config_install/testing_config_install_no_config.tar.gz
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0000400