* Useful when starting positions are made after copying started.
Change-Id: I34d996594753f7bc4449dac96a4822242c1897ee
);
}
+ /**
+ * @see FileJournal::doGetPositionAtTime()
+ * @param $time integer|string timestamp
+ * @return integer|false
+ */
+ protected function doGetPositionAtTime( $time ) {
+ $dbw = $this->getMasterDB();
+
+ $encTimestamp = $dbw->addQuotes( $dbw->timestamp( $time ) );
+ return $dbw->selectField( 'filejournal', 'fj_id',
+ array( 'fj_backend' => $this->backend, "fj_timestamp <= $encTimestamp" ),
+ __METHOD__,
+ array( 'ORDER BY' => 'fj_timestamp DESC' )
+ );
+ }
+
/**
* @see FileJournal::doGetChangeEntries()
* @return Array
*/
abstract protected function doGetCurrentPosition();
+ /**
+ * Get the position ID of the latest journal entry at some point in time
+ *
+ * @param $time integer|string timestamp
+ * @return integer|false
+ */
+ final public function getPositionAtTime( $time ) {
+ return $this->doGetPositionAtTime( $time );
+ }
+
+ /**
+ * @see FileJournal::getPositionAtTime()
+ * @param $time integer|string timestamp
+ * @return integer|false
+ */
+ abstract protected function doGetPositionAtTime( $time );
+
/**
* Get an array of file change log entries.
* A starting change ID and/or limit can be specified.
return false;
}
+ /**
+ * @see FileJournal::doGetPositionAtTime()
+ * @param $time integer|string timestamp
+ * @return integer|false
+ */
+ protected function doGetPositionAtTime( $time ) {
+ return false;
+ }
+
/**
* @see FileJournal::doGetChangeEntries()
* @return Array
$this->addOption( 'end', 'Ending journal ID', false, true );
$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( 'verbose', 'Verbose mode', false, false, 'v' );
$this->setBatchSize( 50 );
}
if ( !$this->hasOption( 'posdir' ) ) {
$this->error( "Param posdir required!", 1 );
}
- $id = (int)$src->getJournal()->getCurrentPosition(); // default to 0
+ if ( $this->hasOption( 'postime' ) ) {
+ $id = (int)$src->getJournal()->getPositionAtTime( $this->getOption( 'postime' ) );
+ } else {
+ $id = (int)$src->getJournal()->getCurrentPosition();
+ }
$this->output( "Current journal position is $id.\n" );
if ( file_put_contents( $posFile, $id, LOCK_EX ) !== false ) {
$this->output( "Saved journal position file.\n" );