Update imapsync_cron.pl

Fix: Reset is_running status in case of exception occurs in running imapsync. Else it will stuck in "running" status.
master
hunter-nl 2019-05-04 11:58:19 +02:00 committed by GitHub
parent 59882b443a
commit 95fe217ce1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -140,12 +140,17 @@ while ($row = $sth->fetchrow_arrayref()) {
$update->bind_param( 2, ${id} ); $update->bind_param( 2, ${id} );
$update->execute(); $update->execute();
} catch { } catch {
$update = $dbh->prepare("UPDATE imapsync SET returned_text = 'Could not start or finish imapsync', last_run = NOW(), is_running = 0 WHERE id = ?"); $update = $dbh->prepare("UPDATE imapsync SET returned_text = 'Could not start or finish imapsync' WHERE id = ?");
$update->bind_param( 1, ${id} );
$update->execute();
} finally {
$update = $dbh->prepare("UPDATE imapsync SET last_run = NOW(), is_running = 0 WHERE id = ?");
$update->bind_param( 1, ${id} ); $update->bind_param( 1, ${id} );
$update->execute(); $update->execute();
$lockmgr->unlock($lock_file); $lockmgr->unlock($lock_file);
}; };
} }
$sth->finish(); $sth->finish();