fsautoproc
Basic file transformation automation management utility
|
fsautoproc is a basic C utility for when:
e.g. you have a large folder of PDFs that is published to a web server. When a new PDF is added, or an existing PDF is modified, you wish to strip any unnecessary file metadata and generate a thumbnail image. If the PDF file is removed, its thumbnail is removed as well.
fsautoproc does not:
Before using, consider:
fsautoproc is built with CMake. You will need a C11 compiler and CMake installed. The utility is primarily written for use on Linux and BSD systems (including macOS). It may work on Windows with WSL or Cygwin, but this is currently untested.
C11 is used for basic atomic boolean operations when scheduling work across threads. C99 compatibility can be achieved by providing a stdatomic.h compatible stub header for your platform.
Git submodules provide:
example.fsautoproc.json provides a basic example configuration file. The configuration file is a JSON array of objects, each object representing a desired "action" at a grouping level of your choosing. Each action object has the following properties:
When executing a command (or a series of commands), the commands are executed in configured order. The parent process is forked, and the child process executes the command using system(3). The parent process waits for the child process to complete before continuing. If a command fails (i.e. returns a non-zero exit status), the parent process logs the failure and processing for that file entry is skipped. Other files in the change set will continue to be processed.
The path of the file that triggered the command is available to the command as an environment variable, FILEPATH.
If -p is enabled, the child process redirects its stdout and stderr to files in the current working directory. The files are named stdout.<thread #>.log and stderr.<thread #>.log, respectively.
fsautoproc uses a symbol table when logging file changes and program status. This minimizes the amount of direct output and improves searchability. Symbols denote a basic file change being detected, and letters indicate program behavior status (i.e. the result of detecting those basic file changes).
Symbol | Purpose |
---|---|
[+] | A new file was created |
[*] | A file was modified |
[-] | A file was deleted/removed |
[j] | A file was ignored/considered junk |
[n] | A file was not detected as modified |
[s] | A directory is being scanned |
[x] | A system command is being invoked |
[!] | An error has occurred |
fsautoproc uses a single, exclusive file lock to prevent multiple instances of the program from running simultaneously within the same search ("working") directory. The lock file is created in the working directory by default, but can be specified via the -x flag. The lock file is removed when the program exits. Should the program crash or exit unexpectedly, the lock file may remain and must be manually removed.