package metadb
Module Metadb.MakeSource
Make a Metadb database
Parameters
Signature
Library configuration
Write database configuration to file. Optional argument is ordering in which libraries should be written
Managing libraries
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.
Rename the given library
Move library to a new path and migrate all files and entries. Raises DirNotEmpty if new directory is not empty
Initializing and refreshing libraries
Initialize a specific library. This loads existing entries and adds a new entry for every new file without entry
Initialize all libraries
Refresh a specific library. This adds a new entry for every new file without entry
Reading and modifying data
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
Remove an entry from a specified library, but leave the file
Remove a file from a specified library, but leave the entry
Move entry and file from one library to another. Raises
EntryExistsif entry already exists into_libFileExistsif file already exists into_libEntryDoesNotExistif entry does not exist infrom_lib
Missing and duplicate files
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 entrykeyhas been moved tolibrary'with new keykey'Missing keysignifies that no file could be associated with entrykey
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
- All libraries are freshly initialized or have been refreshed
- Files have been indexed
Note: Library metadata should be flushed after calling this function to prevent data loss
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
- All libraries are freshly initialized or have been refreshed
- Files have been indexed
This may be called immediately after resolve_missing_files
Writing data to disk
Write modified metadata for specified library to disk
Flush metadata for all libraries
Debugging
Flush entire library to a string, for debugging purposes