7676use OCP \Collaboration \Resources \IManager ;
7777use OCP \Migration \IOutput ;
7878use OCP \Migration \IRepairStep ;
79+ use Psr \Log \LoggerInterface ;
7980use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
8081use Symfony \Component \EventDispatcher \GenericEvent ;
8182
@@ -90,15 +91,18 @@ class Repair implements IOutput {
9091 /** @var string */
9192 private $ currentStep ;
9293
94+ private $ logger ;
95+
9396 /**
9497 * Creates a new repair step runner
9598 *
9699 * @param IRepairStep[] $repairSteps array of RepairStep instances
97100 * @param EventDispatcherInterface $dispatcher
98101 */
99- public function __construct (array $ repairSteps , EventDispatcherInterface $ dispatcher ) {
102+ public function __construct (array $ repairSteps , EventDispatcherInterface $ dispatcher, LoggerInterface $ logger ) {
100103 $ this ->repairSteps = $ repairSteps ;
101104 $ this ->dispatcher = $ dispatcher ;
105+ $ this ->logger = $ logger ;
102106 }
103107
104108 /**
@@ -114,7 +118,12 @@ public function run() {
114118 foreach ($ this ->repairSteps as $ step ) {
115119 $ this ->currentStep = $ step ->getName ();
116120 $ this ->emit ('\OC\Repair ' , 'step ' , [$ this ->currentStep ]);
117- $ step ->run ($ this );
121+ try {
122+ $ step ->run ($ this );
123+ } catch (\Exception $ e ) {
124+ $ this ->logger ->error ("Exception while executing repair step " . $ step ->getName (), ['exception ' => $ e ]);
125+ $ this ->emit ('\OC\Repair ' , 'error ' , [$ e ->getMessage ()]);
126+ }
118127 }
119128 }
120129
0 commit comments