Library Implementation

This section documents dantalian’s library implementation. See Library Specification for a reference to the library specification.

Library

Library is the actual implementation that dantalian provides. It implements the following public methods and invariants in addition to those described in Library class and methods (Filename/path conflicts will be resolved according to File Renaming Algorithm.):

Note

dantalian respects symbolic links to directories outside of the library (Symbolic links to directories inside of the library, on the other hand, should always be converted by dantalian. Handmade symbolic links to library-internal paths subject to breakage and Armageddon.).

For simple operations, dantalian will act as though external symlinked directories are a part of the library. For complex operations, these external directories will be ignored (This is because dantalian is not really descending symbolic links, but only acting on the directories stored internally. This simulates only descending into internal symbolic links.). The latter case will be noted below if applicable.

tag(file, tag)

If file does not have a hard link under the tag directory, make one. file has at least one hard link under the tag directory after call.

untag(file, tag)

file should not be tagged with tag after call, regardless of whether it was before.

mktag(tag)

The directory corresponding to tag is created. Do nothing if it exists.

rmtag(tag)

The directory corresponding to tag is removed. Do nothing if it doesn’t exist.

listtags(file)

Return a list of all of the tags of file.

find(tags)

Return a list of files that have all of the given tags in tags.

mount(path, tree)

Mount a virtual representation of the library representation tree at path.

The following are methods that are not in the abstract library interface:

convert(dir)

Store directory dir internally and replace the original with a symbolic link with the same name pointing to the absolute path of the stored directory. Resolve name conflict if necessary (if a file with the same name is made in between moving the directory and creating the symbolic link, for example).

cleandirs()

Remove all directories stored internally that no longer have any symbolic links referring to them in the library.

rm(file)

Remove all hard links to file in the library. Any errors will be reported and removal will resume for remaining hard links.

Note

rm() does not descend into symbolic links to external directories.

rename(file, new)

Rename all hard links to file in the library to new. File name conflicts are resolved and reported. Any errors will be reported and renaming will resume for remaining hard links.

Note

rename() does not descend into symbolic links to external directories.

fix()

Fix the absolute paths of symbolic links in the library to internally stored directories after the library’s path has been changed. Hard link relationships of the symbolic links are preserved only in the library. (This is because the Linux kernel/POSIX system calls do not allow for editing symbolic links in place. They must be unlinked and remade.) Symbolic links are unlinked and a new symbolic link is made then relinked. Filename conflicts are resolved and reported (if a file with the same name is made in between deleting and creating the symbolic link, for example).

maketree()

Return a tree generated using the library’s configuration files.

ProxyLibrary

ProxyLibrary is a subclass of Library for virtual FUSE mounted libraries. It overrides the following methods:

fix()

Log a warning and do nothing. (Action not allowed.)

mount(path, tree)

Log a warning and do nothing. (Action not allowed.)