From fe766ce30ec0ba4072e9d0565cbd2f1ebcbcf741 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Thu, 20 Apr 2023 13:28:45 -0700 Subject: [PATCH] other: use direct for places setup Signed-off-by: Varun Patil --- lib/Controller/OtherController.php | 38 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/Controller/OtherController.php b/lib/Controller/OtherController.php index 46e53243..eaa05297 100644 --- a/lib/Controller/OtherController.php +++ b/lib/Controller/OtherController.php @@ -207,28 +207,28 @@ class OtherController extends GenericApiController // Reset action token $this->actionToken(true); - try { - // Set PHP timeout to infinite - set_time_limit(0); + return Util::guardExDirect(function (Http\IOutput $out) { + try { + // Set PHP timeout to infinite + set_time_limit(0); - // Send headers for long-running request - header('Content-Type: text/plain'); - header('X-Accel-Buffering: no'); - header('Cache-Control: no-cache'); - header('Connection: keep-alive'); - header('Content-Length: 0'); + // Send headers for long-running request + $out->setHeader('Content-Type: text/plain'); + $out->setHeader('X-Accel-Buffering: no'); + $out->setHeader('Cache-Control: no-cache'); + $out->setHeader('Connection: keep-alive'); + $out->setHeader('Content-Length: 0'); - $places = \OC::$server->get(\OCA\Memories\Service\Places::class); - $datafile = $places->downloadPlanet(); - $places->importPlanet($datafile); - $places->recalculateAll(); + $places = \OC::$server->get(\OCA\Memories\Service\Places::class); + $datafile = $places->downloadPlanet(); + $places->importPlanet($datafile); + $places->recalculateAll(); - echo "Done.\n"; - } catch (\Exception $e) { - echo 'Failed: '.$e->getMessage()."\n"; - } - - exit; + $out->setOutput("Done.\n"); + } catch (\Exception $e) { + $out->setOutput('Failed: '.$e->getMessage()."\n"); + } + }); } /**