mgree / ffs

the file filesystem: mount semi-structured data (like JSON) as a Unix filesystem
https://mgree.github.io/ffs/
GNU General Public License v3.0
449 stars 14 forks source link

Empty file mounting fails #58

Open nkh opened 2 years ago

nkh commented 2 years ago

$> touch x.json $> ffs x.son thread 'main' panicked at 'JSON: Error("EOF while parsing a value", line: 1, column: 0)', src/format.rs:187:53 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

mgree commented 2 years ago

What did you expect to happen when you supplied invalid JSON?

(NB that a .json file must contain exactly one value in the sense of RFC 8259.)

nkh commented 2 years ago

given the RFC the output is certainly OK but intuitively I would have expected an empty directory

mgree commented 2 years ago

If that's what you want, there's the --empty flag.

That said, I'd accept a PR that implemented your behavior---you'd have to catch the error, identify that it's because of an empty file (parse error message/call stat?), and then return an empty object. Might be good to create a --strict flag that turns off this behavior, in case someone wants to rely on correct JSON/etc. parsing.