#files #filesystem #organization

bin+lib card_catalog

Assists in collecting file metadata for later organization

9 stable releases

1.0.8 Jan 6, 2019
1.0.7 Jan 5, 2019
1.0.6 Dec 1, 2018
1.0.4 Nov 25, 2018
1.0.2 Nov 24, 2018

#77 in Filesystem

Download history 64/week @ 2018-11-30 69/week @ 2018-12-07 14/week @ 2018-12-14 8/week @ 2018-12-21 28/week @ 2018-12-28 7/week @ 2019-01-04 44/week @ 2019-01-11

68 downloads per month

MIT license

27KB
589 lines

Card Catalog

Build Status

Written in Rust, this program collects file metadata and stores it in a PostgreSQL database. Some things it gathers include:

  1. File name
  2. Path
  3. Size
  4. XxHash checksum

In addition to collecting data about files, the program assists in indexing files with tools such as file tagging, search, and more. Development on these features is underway... stay tuned!

Getting Started

To run the project, you will need a PostgreSQL database setup and configure the .env file in this project to point to your database. See Configuration section below.

Next, you will need to use diesel to run the database migrations necessary to create tables needed for the project.

diesel migration run

Next, set any remaining configuration values as detailed in Configuration.

Once the prerequisites are met, you may run or build the project with:

# To see help
cargo run -- --help

# To run
cargo run

# To build for release
cargo build --release

See Arguments section for details on the arguments this program accepts.

Note: if running on Ubuntu, you may need to install libpq-dev in order for Diesel to compile when cargo builds.

sudo apt install libpq-dev

Arguments

This app takes a minimum of one command line argument before it will perform any action beyond simply terminating. This section is divided into commands subcommands.

Commands

Action

You can specify one of several actions to use via the -a or --action command flags followed by an action name. For now configuration beyond selecting an action to perform is handled in the .env file, see Configuration. Valid actions are:

  1. duplicates - finds duplicate files within database via matching hashes.
  2. hash - computes hashes, file size, etc and stores results in database.
  3. orphans - iterates all database entries computed by hash action and does a simple check to see if files are still present. If a file is not present, its entry in the database will be removed.

Examples:

# Start hashing files:
cargo run -- --action hash

Subcommands

Creating a Tag

To create a tag without applying it to a listing, eg "puppy" use

cargo run -- new-tag puppy

Tagging a Listing

To aid in searching for any given file, you can apply tags to a listing id which in the future will be used as a search mechanism. For example, you could search for all files containing the tag vacation and viola 🎻, all files with the tag applied are returned!

To tag a listing, whose id is 56982fc3-091a-489c-bd6c-c7f916965d4b, with tags of summer, beach, and vacation:

cargo run -- tag 56982fc3-091a-489c-bd6c-c7f916965d4b -- summer beach vacation

Removing a Tag from a Listing

To remove a single tag applied to a listing, use the UUID in the id column of listing_tags to remove the applied tag association.

cargo run -- delete-tag-listing 56982fc3-091a-489c-bd6c-c7f916965d4b

Deleting a Tag

Deleting a tag will remove it from the tags table and all entries of where the tag was in use on the listing_tags table. Proceed with caution! To make this a little harder to accidentally run, for now tags must be deleted with their UUID in the id column within the tags table.

cargo run -- delete-tag 56982fc3-091a-489c-bd6c-c7f916965d4b

Configuration

.env configuration setting include:

  1. DATABASE_URL - PostgreSQL connection string.
  2. DIRECTORY_TO_SCAN - root directory location to start scanning files from.

License

License is MIT. See LICENSE file.

Dependencies

~7.5MB
~147K SLoC