diff --git a/visidata/loaders/archive.py b/visidata/loaders/archive.py index f3cba13e3..ffb156077 100644 --- a/visidata/loaders/archive.py +++ b/visidata/loaders/archive.py @@ -5,18 +5,21 @@ from visidata.loaders import unzip_http from visidata import vd, VisiData, asyncthread, Sheet, Progress, Menu, options -from visidata import ColumnAttr, Column, Path +from visidata import ColumnAttr, Column, Path, filesize from visidata.type_date import date @VisiData.api def guess_zip(vd, p): if not p.is_url() and zipfile.is_zipfile(p.open_bytes()): - return dict(filetype='zip') + return dict(filetype='zip', _likelihood=10) @VisiData.api def guess_tar(vd, p): + # an empty file will pass is_tarfile(), but can't be opened by tarfile.open() + if filesize(p) == 0: + return None if tarfile.is_tarfile(p.open_bytes()): - return dict(filetype='tar') + return dict(filetype='tar', _likelihood=10) @VisiData.api def open_zip(vd, p): diff --git a/visidata/loaders/sqlite.py b/visidata/loaders/sqlite.py index f8a9ecd49..1cf29b4de 100644 --- a/visidata/loaders/sqlite.py +++ b/visidata/loaders/sqlite.py @@ -20,7 +20,7 @@ def requery(url, **kwargs): @VisiData.api def guess_sqlite(vd, p): if p.open_bytes().read(16).startswith(b'SQLite format'): - return dict(filetype='sqlite') + return dict(filetype='sqlite', _likelihood=10) @VisiData.api