package metadb

  1. Overview
  2. Docs

Metadb is a library to locally store and manipulate a JSON database of file metadata. A key feature of Metadb is that a user may rename or move files within or between libraries, and Metadb will resolve missing or renamed files according to their MD5 hash. Metadb can also find duplicate files across libraries.

A database is composed of one or more libraries, each of which points to a specific directory in the $HOME path. A library may have metadata specified by LibData, such as its version of the type of its entries. Name, path, and metadata of each library is stored as JSON in a configuration file which may be read and written by Make.load_config and Make.write_config. For example, such a file may be stored in $HOME/.config/libraries.json.

Each library assigns a JSON file to each file in its associated directory, for example, consider a library named "documents" that points to a directory ~/Documents/Articles and suppose the following files are contained in this library:

~/Documents/Articles/

  • article1.pdf
  • article2.djvu
  • path/to/article3.pdf

Then Metadb will store metadata for each file specified by Metadata in a hidden directory ./.metadata: ~/Documents/Articles/.metadata

  • article1.pdf.json
  • article2.djvu.json
  • path/to/article3.pdf.json

The key to an entry or file in a library is always given by its relative path with respect to the library's root path.

exception FileExists of Path.root
exception EntryExists of string * Path.rel
exception EntryDoesNotExist of string * Path.rel
exception DirNotEmpty of Path.root
exception LibraryExists
module Path : module type of Path

A minimal library for manipulating typed representations of paths

module Hash : module type of Hash

This is a wrapper for the standard Digest library.

module Json : module type of Json

This is a wrapper for the Yojson library

module System : module type of System

This is a wrapper for the standard Sys library.

module type Metadata = sig ... end

Metadata to be associated to each file in a library

module type LibData = sig ... end

Metadata associated to each library

module Make (D : Metadata) (LD : LibData) : sig ... end

Make a Metadb database

OCaml

Innovation. Community. Security.