Ask HN: Tool for Validating Filesystem Structure
Each folder in the root application directory belongs to a user (identified by id), and subsequent subfolders identify a project. There are certain requirements for the name of each user folder and each project folder, and inside each project folder some other files and folders must necessarily exist, and extra ones should never.
I'm wondering if a tool or type of filesystem exists that lets me enforce structure, much like an SQL database would enforce relationships and datatypes in a given column. I could have written a script to do such validations, but it seems like a frequent enough problem that a general-purpose tool should exist, and it would be easier to maintain a bunch of rule files over a complex script.
Validations would include: - in this depth of filesystem, only folders can exist (no files), and should match this regex - files named "projectCover.png" under a project folder should not exceed a certain file size - each project folder should have a folder named "uploads", and for each file inside it, a "thumbnails/<file>.png" should also exist.
Another validation isn't as trivial: database rows have file paths which should point to images in the filesystem, and I would wish to validate that these indeed exist. Storing binaries in the filesystem would remove these possible data inconsistencies, but has practical issues.