refactor CLI command modules and synchronize docs
This commit is contained in:
+48
-6
@@ -93,8 +93,17 @@ class ExecutionEngine:
|
||||
transaction_log = None
|
||||
if mode == "execute":
|
||||
log_path = Path.home() / ".vlm" / "transaction.json"
|
||||
transaction_log = TransactionLog(log_path)
|
||||
transaction_log.start_transaction(plan)
|
||||
try:
|
||||
transaction_log = TransactionLog(log_path)
|
||||
transaction_log.start_transaction(plan)
|
||||
except OSError as exc:
|
||||
log_operation(
|
||||
self.logger,
|
||||
logging.WARNING,
|
||||
f"Transaction log disabled (cannot write {log_path}): {exc}",
|
||||
operation_type="execute",
|
||||
)
|
||||
transaction_log = None
|
||||
|
||||
# Execute all operations
|
||||
results = []
|
||||
@@ -105,9 +114,18 @@ class ExecutionEngine:
|
||||
# Update transaction and state logs in execute mode
|
||||
if mode == "execute":
|
||||
if transaction_log:
|
||||
transaction_log.mark_operation_complete(
|
||||
i, result.success, result.error_message
|
||||
)
|
||||
try:
|
||||
transaction_log.mark_operation_complete(
|
||||
i, result.success, result.error_message
|
||||
)
|
||||
except OSError as exc:
|
||||
log_operation(
|
||||
self.logger,
|
||||
logging.WARNING,
|
||||
f"Failed to update transaction log: {exc}",
|
||||
operation_type="execute",
|
||||
)
|
||||
transaction_log = None
|
||||
|
||||
# Update file state if successful and not a no-op
|
||||
if result.success and operation.operation_type != "no-op" and self.state_manager:
|
||||
@@ -126,7 +144,15 @@ class ExecutionEngine:
|
||||
if mode == "execute":
|
||||
if transaction_log:
|
||||
status = "completed" if all(r.success for r in results) else "failed"
|
||||
transaction_log.complete_transaction(status=status)
|
||||
try:
|
||||
transaction_log.complete_transaction(status=status)
|
||||
except OSError as exc:
|
||||
log_operation(
|
||||
self.logger,
|
||||
logging.WARNING,
|
||||
f"Failed to finalize transaction log: {exc}",
|
||||
operation_type="execute",
|
||||
)
|
||||
if self.state_manager:
|
||||
self.state_manager.save()
|
||||
|
||||
@@ -189,6 +215,22 @@ class ExecutionEngine:
|
||||
executed_at=executed_at
|
||||
)
|
||||
|
||||
# Handle preserve-directory operations
|
||||
if operation.operation_type == "preserve-directory":
|
||||
log_operation(
|
||||
self.logger,
|
||||
logging.DEBUG,
|
||||
f"Preserving directory: {operation.reason}",
|
||||
operation_type="execute",
|
||||
file_path=operation.source_path
|
||||
)
|
||||
return OperationResult(
|
||||
operation=operation,
|
||||
success=True,
|
||||
error_message=None,
|
||||
executed_at=executed_at
|
||||
)
|
||||
|
||||
# Handle quarantine operations (no destination_path; use QuarantineManager)
|
||||
if operation.operation_type == "quarantine":
|
||||
if not self._quarantine_manager:
|
||||
|
||||
Reference in New Issue
Block a user