From 935318dda6495a1b363bb73723c02ab0aa816797 Mon Sep 17 00:00:00 2001 From: Eli Bosley Date: Tue, 4 Feb 2025 10:35:14 -0500 Subject: [PATCH] feat: docstrings --- .../unraid-file-modifier.service.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/api/src/unraid-api/unraid-file-modifier/unraid-file-modifier.service.ts b/api/src/unraid-api/unraid-file-modifier/unraid-file-modifier.service.ts index a182f71ff..af7008b2e 100644 --- a/api/src/unraid-api/unraid-file-modifier/unraid-file-modifier.service.ts +++ b/api/src/unraid-api/unraid-file-modifier/unraid-file-modifier.service.ts @@ -12,6 +12,9 @@ export class UnraidFileModificationService implements OnModuleInit, OnModuleDest private readonly logger = new Logger(UnraidFileModificationService.name); private appliedModifications: FileModification[] = []; + /** + * Load and apply all modifications on module init + */ async onModuleInit() { try { this.logger.log('Loading file modifications...'); @@ -24,11 +27,18 @@ export class UnraidFileModificationService implements OnModuleInit, OnModuleDest } } + /** + * Rollback all applied modifications on module destroy + */ async onModuleDestroy() { this.logger.log('Rolling back all modifications...'); await this.rollbackAll(); } + /** + * Load all modifications + * @returns An array of all loaded modifications + */ async loadModifications(): Promise { const modifications: FileModification[] = []; const modificationClasses: Array FileModification> = [ @@ -51,6 +61,10 @@ export class UnraidFileModificationService implements OnModuleInit, OnModuleDest } } + /** + * Apply a single modification + * @param modification - The modification to apply + */ async applyModification(modification: FileModification): Promise { try { const shouldApplyWithReason = await modification.shouldApply(); @@ -78,8 +92,10 @@ export class UnraidFileModificationService implements OnModuleInit, OnModuleDest } } + /** + * Rollback all applied modifications + */ async rollbackAll(): Promise { - // Process modifications in reverse order for (const modification of [...this.appliedModifications].reverse()) { try { this.logger.log(`Rolling back modification: ${modification.id}`);