@@ -12,6 +12,9 @@ export class UnraidFileModificationService implements OnModuleInit, OnModuleDest
1212 private readonly logger = new Logger ( UnraidFileModificationService . name ) ;
1313 private appliedModifications : FileModification [ ] = [ ] ;
1414
15+ /**
16+ * Load and apply all modifications on module init
17+ */
1518 async onModuleInit ( ) {
1619 try {
1720 this . logger . log ( 'Loading file modifications...' ) ;
@@ -24,11 +27,18 @@ export class UnraidFileModificationService implements OnModuleInit, OnModuleDest
2427 }
2528 }
2629
30+ /**
31+ * Rollback all applied modifications on module destroy
32+ */
2733 async onModuleDestroy ( ) {
2834 this . logger . log ( 'Rolling back all modifications...' ) ;
2935 await this . rollbackAll ( ) ;
3036 }
3137
38+ /**
39+ * Load all modifications
40+ * @returns An array of all loaded modifications
41+ */
3242 async loadModifications ( ) : Promise < FileModification [ ] > {
3343 const modifications : FileModification [ ] = [ ] ;
3444 const modificationClasses : Array < new ( logger : Logger ) => FileModification > = [
@@ -51,6 +61,10 @@ export class UnraidFileModificationService implements OnModuleInit, OnModuleDest
5161 }
5262 }
5363
64+ /**
65+ * Apply a single modification
66+ * @param modification - The modification to apply
67+ */
5468 async applyModification ( modification : FileModification ) : Promise < void > {
5569 try {
5670 const shouldApplyWithReason = await modification . shouldApply ( ) ;
@@ -78,8 +92,10 @@ export class UnraidFileModificationService implements OnModuleInit, OnModuleDest
7892 }
7993 }
8094
95+ /**
96+ * Rollback all applied modifications
97+ */
8198 async rollbackAll ( ) : Promise < void > {
82- // Process modifications in reverse order
8399 for ( const modification of [ ...this . appliedModifications ] . reverse ( ) ) {
84100 try {
85101 this . logger . log ( `Rolling back modification: ${ modification . id } ` ) ;
0 commit comments