Index#
- class barecat.Index(path, shard_size_limit=None, bufsize=None, readonly=True, wal=False, readonly_is_immutable=False)[source]#
Bases:
contextlib.AbstractContextManagerManages the SQLite database storing metadata about the files and directories in the Barecat archive.
- Parameters:
path (Union[str, PathLike]) – Path to the SQLite database file (e.g., ‘archive.barecat’).
shard_size_limit (Union[int, str, None]) – Maximum size of a shard in bytes (int) or as a string like ‘1G’. If None, the shard size is unlimited.
bufsize (Optional[int]) – Buffer size for fetching rows.
readonly (bool) – Whether to open the index in read-only mode.
wal (bool)
readonly_is_immutable (bool)
Properties#
Number of files in the index. |
|
Number of directories in the index. |
|
Total size of all files in the index, in bytes. |
|
The maximum allowed shard size, in bytes. Upon reaching this limit, a new shard is |
|
Number of shards where final, logically empty shards are not counted. |
Instance Methods#
|
Look up a file by its path. |
|
Look up multiple files by their paths. |
|
Look up a directory by its path. |
|
Look up a file or directory by its path. |
|
Number of files in the index. |
|
Iterate over all file info objects in the index. |
|
Check if a file exists in the index. |
|
Check if a file exists in the index. |
|
Check if a directory exists in the index. |
|
Check if a file or directory exists in the index. |
|
Iterate over all file info objects in the index. |
|
List the file info objects in a directory (non-recursively). |
|
List the subdirectory info objects contained in a directory (non-recursively). |
|
Iterate over the file info objects in a directory (non-recursively). |
|
Iterate over the subdirectory info objects contained in a directory (non-recursively). |
|
List the names of the files and subdirectories in a directory (non-recursively). |
|
List the file and directory info objects in a directory (non-recursively). |
|
Iterate over the names of the files and subdirectories in a directory (non-recursively). |
|
Iterate over the file and directory info objects in a directory (non-recursively). |
|
Glob for paths matching a pattern. |
|
Iterate over paths matching a pattern. |
|
Iterate over file and directory info objects matching a pattern. |
|
Iterate over infos matching rsync-style include/exclude rules. |
|
Walk over the directory tree starting from a directory. |
|
Walk over the directory tree starting from a directory. |
Return the last file in the index, i.e., the one with the highest offset in the last |
|
|
Return the logical end offset of a shard, which is the index of a byte immediately after |
|
Add a file or directory to the index. |
|
Add a file to the index. |
|
Add multiple files to the index. |
|
Update file metadata in the index. |
|
Add a directory to the index. |
|
Rename a file or directory in the index. |
|
Rename a file in the index. |
|
Rename a directory in the index. |
|
Remove a file from the index. |
|
Remove multiple files from the index. |
|
Remove an empty directory from the index. |
|
Remove a directory and all its contents recursively. |
|
Change the mode of a file or directory. |
|
Change the owner and group of a file or directory. |
|
Update the modification time of a file or directory. |
Verify the integrity of the index. |
|
|
Adds the files and directories from another Barecat index to this one. |
|
Check for file/directory conflicts with attached sourcedb. |
Recompute size_tree and num_files_tree for all directories. |
|
Ensure all ancestor directories exist for both files and dirs. |
|
Context manager to temporarily disable triggers. |
|
|
Context manager for bulk operations with automatic cleanup. |
|
Context manager to attach another SQLite database temporarily. |
|
Close the index. |
|
Optimize the index. |
|
Exit the context manager. |