Library
Module
Module type
Parameter
Class
Class type
Make a Metadb
database
val load_config : Path.root -> unit
Load database configurations from file
val write_config : ?ord:string list -> Path.root -> unit
Write database configuration to file. Optional argument is ordering in which libraries should be written
Create a new library with name library
pointing to the given path
Remove the given library. If delete_metadata
is true, the .metadata
directory will be deleted as well.
val move_library : library:string -> Path.root -> unit
Move library to a new path and migrate all files and entries. Raises DirNotEmpty
if new directory is not empty
Initialize a specific library. This loads existing entries and adds a new entry for every new file without entry
Refresh a specific library. This adds a new entry for every new file without entry
val get_libdata : unit -> (string * LD.t) list
Get all libraries and their associated metadata
val get_library_root : library:string -> Path.root
Returns root path of specified library
Get all entries of a specified library and their associated metadata
If it exists, get the value of an entry in the specified library. The key to an entry is the relative path of the file with respect to the library's root
Set the value of an entry in the specified library. Raises EntryDoesNotExist
if key does not exist
val remove_entry : library:string -> Path.rel -> unit
Remove an entry from a specified library, but leave the file
val remove_file : library:string -> Path.rel -> unit
Remove a file from a specified library, but leave the entry
val migrate_entry : from_lib:string -> to_lib:string -> Path.rel -> unit
Move entry and file from one library to another. Raises
EntryExists
if entry already exists in to_lib
FileExists
if file already exists in to_lib
EntryDoesNotExist
if entry does not exist in from_lib
Needed in order to quickly resolve missing files or find duplicates. This should only be called after freshly initializing or refreshing a library
Return type of resolve_missing_files
.
Remap (key, (library',key'))
signifies that entry key
has been moved to library'
with new key key'
Missing key
signifies that no file could be associated with entry key
val resolve_missing_files : library:string -> resolution Seq.t
Attempt to resolve entries that are no longer pointing to a file. For each entry no longer pointing to a file, this function searches accross all libraries for a file with matching hash. If an entry to the corresponding file exists, attempt to merge both entries. This function assumes
Note: Library metadata should be flushed after calling this function to prevent data loss
val find_duplicates : unit -> (string * Path.rel) list list
Return a partition of the duplicate files, of the form:
[[(lib_11, file_11), (lib_12, file_12),...]
[(lib_21, file_21), (lib_22, file_22),...]
...
[(lib_n1, file_n1), (lib_n2, file_n2),...]]
such that entries in each row are duplicate files having the same hash. This function assumes
This may be called immediately after resolve_missing_files
Write modified metadata for specified library to disk