Skip to content

Commit 810aa27

Browse files
author
Julien Veyssier
committed
refs #60 catch any unhandled error in import jobs
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
1 parent 8dc8968 commit 810aa27

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎lib/Service/GoogleDriveAPIService.php‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,13 @@ public function importDriveJob(string $userId): void {
177177
// import by batch of 500 Mo
178178
$alreadyImported = $this->config->getUserValue($userId, Application::APP_ID, 'nb_imported_files', '0');
179179
$alreadyImported = (int) $alreadyImported;
180-
$result = $this->importFiles($accessToken, $userId, $targetPath, 500000000, $alreadyImported, $directoryProgress);
180+
try {
181+
$result = $this->importFiles($accessToken, $userId, $targetPath, 500000000, $alreadyImported, $directoryProgress);
182+
} catch (\Exception | \Throwable $e) {
183+
$result = [
184+
'error' => 'Unknow job failure. ' . $e->getMessage(),
185+
];
186+
}
181187
if (isset($result['error']) || (isset($result['finished']) && $result['finished'])) {
182188
if (isset($result['finished']) && $result['finished']) {
183189
$nbImported = (int) $this->config->getUserValue($userId, Application::APP_ID, 'nb_imported_files', '0');

‎lib/Service/GooglePhotosAPIService.php‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,13 @@ public function importPhotosJob(string $userId): void {
174174
// import photos by batch of 500 Mo
175175
$alreadyImported = $this->config->getUserValue($userId, Application::APP_ID, 'nb_imported_photos', '0');
176176
$alreadyImported = (int) $alreadyImported;
177-
$result = $this->importPhotos($accessToken, $userId, $targetPath, 500000000, $alreadyImported);
177+
try {
178+
$result = $this->importPhotos($accessToken, $userId, $targetPath, 500000000, $alreadyImported);
179+
} catch (\Exception | \Throwable $e) {
180+
$result = [
181+
'error' => 'Unknow job failure. ' . $e->getMessage(),
182+
];
183+
}
178184
if (isset($result['error']) || (isset($result['finished']) && $result['finished'])) {
179185
$this->config->setUserValue($userId, Application::APP_ID, 'importing_photos', '0');
180186
$this->config->setUserValue($userId, Application::APP_ID, 'nb_imported_photos', '0');

0 commit comments

Comments
 (0)