boolean undoChanges ( ) { final State state = stateUpdater . getAndSet ( this , State . ROLLBACK_ONLY ) ; if ( state == State . COMPLETED || state == State . ROLLBACK_ONLY ) { // Was actually completed already return false ; } PatchingTaskContext . Mode currentMode = this . mode ; mode = PatchingTaskContext . Mode . UNDO ; final PatchContentLoader loader = PatchContentLoader . create ( miscBackup , null , null ) ; // Undo changes for the identity undoChanges ( identityEntry , loader ) ; // TODO maybe check if we need to do something for the layers too !? if ( state == State . INVALIDATE || currentMode == PatchingTaskContext . Mode . ROLLBACK ) { // For apply the state needs to be invalidate // For rollback the files are invalidated as part of the tasks final PatchingTaskContext . Mode mode = currentMode == PatchingTaskContext . Mode . APPLY ? PatchingTaskContext . Mode . ROLLBACK : PatchingTaskContext . Mode . APPLY ; for ( final File file : moduleInvalidations ) { try { PatchModuleInvalidationUtils . processFile ( this , file , mode ) ; } catch ( Exception e ) { PatchLogger . ROOT_LOGGER . debugf ( e , "failed to restore state for %s" , file ) ; } } if ( ! modulesToReenable . isEmpty ( ) ) { for ( final File file : modulesToReenable ) { try { PatchModuleInvalidationUtils . processFile ( this , file , PatchingTaskContext . Mode . APPLY ) ; } catch ( Exception e ) { PatchLogger . ROOT_LOGGER . debugf ( e , "failed to restore state for %s" , file ) ; } } } if ( ! modulesToDisable . isEmpty ( ) ) { for ( final File file : modulesToDisable ) { try { PatchModuleInvalidationUtils . processFile ( this , file , PatchingTaskContext . Mode . ROLLBACK ) ; } catch ( Exception e ) { PatchLogger . ROOT_LOGGER . debugf ( e , "failed to restore state for %s" , file ) ; } } } } return true ; }
Internally undo recorded changes we did so far .