From: Aaron Schulz Date: Wed, 1 May 2013 01:53:01 +0000 (-0700) Subject: Added a --backoff option for syncFileBackend.php X-Git-Tag: 1.31.0-rc.0~19764^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=75e51f6ac4a0905a53e1ab68a0547e7fc15caa54;p=lhc%2Fweb%2Fwiklou.git Added a --backoff option for syncFileBackend.php * This is useful for avoiding in-progress operations if locking is not enabled (the journal is updated before file changes). Change-Id: Ieab3b157a6858f68cc9259214cac1743b7525da0 --- diff --git a/maintenance/syncFileBackend.php b/maintenance/syncFileBackend.php index 158019b7d0..e5d755ed59 100644 --- a/maintenance/syncFileBackend.php +++ b/maintenance/syncFileBackend.php @@ -40,6 +40,7 @@ class SyncFileBackend extends Maintenance { $this->addOption( 'posdir', 'Directory to read/record journal positions', false, true ); $this->addOption( 'posdump', 'Just dump current journal position into the position dir.' ); $this->addOption( 'postime', 'For position dumps, get the ID at this time', false, true ); + $this->addOption( 'backoff', 'Stop at entries younger than this age (sec).', false, true ); $this->addOption( 'verbose', 'Verbose mode', false, false, 'v' ); $this->setBatchSize( 50 ); } @@ -88,7 +89,13 @@ class SyncFileBackend extends Maintenance { } else { $startFromPosFile = false; } - $end = $this->getOption( 'end', INF ); + + if ( $this->hasOption( 'backoff' ) ) { + $time = time() - $this->getOption( 'backoff', 0 ); + $end = (int)$src->getJournal()->getPositionAtTime( $time ); + } else { + $end = $this->getOption( 'end', INF ); + } $this->output( "Synchronizing backend '{$dst->getName()}' to '{$src->getName()}'...\n" ); $this->output( "Starting journal position is $start.\n" );