adsfolio.pdf.tracked_move
Filesystem moves kept consistent with the PDF catalog.
- class adsfolio.pdf.tracked_move.TrackedFileState(*args, **kwargs)[source]
Bases:
ProtocolState operations required for a catalog-consistent file move.
- directory: pathlib.Path
- exception adsfolio.pdf.tracked_move.TrackedMoveConflictError(source, destination)[source]
Bases:
FileExistsErrorReport a move destination that already exists as a distinct file.
- Parameters:
source (Path)
destination (Path)
- Return type:
None
- exception adsfolio.pdf.tracked_move.TrackedMoveRollbackError[source]
Bases:
RuntimeErrorReport both catalog and filesystem rollback failures.
- adsfolio.pdf.tracked_move.is_same_file_alias(source_path, destination_path)[source]
Check whether two paths name the exact same directory entry.
Returns True when both paths reference the same device and inode in the same parent directory, neither path is a symlink, and the destination name is not an independently existing directory entry (such as a hard link).
- Parameters:
source_path (pathlib.Path)
destination_path (pathlib.Path)
- Return type:
- adsfolio.pdf.tracked_move.move_tracked_file(state, source_path, destination_path)[source]
Move one tracked file and update its root-relative catalog location.
The filesystem move is rolled back if the catalog update fails.
- Parameters:
source_path (pathlib.Path)
destination_path (pathlib.Path)
- Return type:
- adsfolio.pdf.tracked_move.move_tracked_file_outside_root(state, source_path, destination_path)[source]
Move a selected PDF outside its library and retain its location history.
- Parameters:
state (CentralPdfRegistryState) – Open catalog state for the source library.
source_path (Path) – Current path of the tracked PDF inside the library root.
destination_path (Path) – New path outside the root on the same filesystem.
- Returns:
Destination after the catalog marks the old location missing.
- Return type:
Path
- Raises:
ValueError – The source lies outside the root or the destination lies inside it.
KeyError – The source has no tracked location.
OSError – The exclusive file move failed.
TrackedMoveRollbackError – A catalog failure also prevented filesystem rollback.
Notes
Catalog failure rolls the file move back without replacing another file.
- adsfolio.pdf.tracked_move.resolved_file_directory(root, source_path, unresolved_directory=None)[source]
Choose the directory for a resolved PDF within one catalog root.
- Parameters:
root (Path) – Library root owning the file’s catalog location.
source_path (Path) – Current PDF path.
unresolved_directory (Path, optional) – Configured unresolved directory, relative to root when not absolute. Defaults to
<root>/unresolved.
- Returns:
The library root for files below its unresolved subtree; otherwise the source parent. An external directory or the root itself is not treated as an unresolved subtree because its owning library is ambiguous.
- Return type:
Path