mirror of
https://github.com/allaunthefox/Research-Stack.git
synced 2026-07-31 03:05:21 +00:00
1.5 KiB
1.5 KiB
Transaction API
TransactionLog
Logs operations for rollback capability.
Constructor
TransactionLog(log_dir: str = ".nodupe/backups")
Methods
begin_transaction
def begin_transaction(self) -> str
Start a new transaction.
Returns: Transaction ID
log_operation
def log_operation(self, operation: Operation) -> None
Log an operation in the current transaction.
Parameters:
operation: Operation to log
commit_transaction
def commit_transaction(self) -> str
Commit the transaction.
Returns: Final status
rollback_transaction
def rollback_transaction(self, transaction_id: str) -> bool
Rollback all operations in a transaction.
Parameters:
transaction_id: ID of transaction to rollback
Returns: True if successful
list_transactions
def list_transactions(self) -> list[dict]
List all transactions.
Returns: List of transaction summaries
Operation
Represents a single operation in a transaction.
Constructor
Operation(
operation_type: str,
path: str,
original_hash: Optional[str] = None,
backup_path: Optional[str] = None,
new_path: Optional[str] = None
)
Properties
operation_type: Type of operation (delete, modify, move, copy, restore)path: File pathoriginal_hash: Original file hashbackup_path: Backup file pathnew_path: New path (for move operations)