Skip to content

Commit 1be485b

Browse files
committed
fix: index add check to confirm that only uncompressed CSV file dialects can be indexed
1 parent e760d44 commit 1be485b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/cmd/index.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,16 @@ struct Args {
4949
pub fn run(argv: &[&str]) -> CliResult<()> {
5050
let args: Args = util::get_args(USAGE, argv)?;
5151

52-
if args.arg_input.to_lowercase().ends_with(".sz") {
53-
return fail_incorrectusage_clierror!("Cannot index a snappy file.");
52+
// can only index CSV, TSV, or TAB files
53+
let exts = ["csv", "tsv", "tab", "ssv"];
54+
let input_path = Path::new(&args.arg_input);
55+
let ext = input_path
56+
.extension()
57+
.and_then(std::ffi::os_str::OsStr::to_str)
58+
.map(str::to_ascii_lowercase);
59+
60+
if ext.as_deref().is_none_or(|e| !exts.contains(&e)) {
61+
return fail_incorrectusage_clierror!("Can only index CSV, TSV/TAB or SSV files.");
5462
}
5563

5664
let pidx = match args.flag_output {

0 commit comments

Comments
 (0)