Code Duplication    Length = 25-25 lines in 2 locations

sync/class.jetpack-sync-actions.php 2 locations

@@ 222-246 (lines=25) @@
219
	// try to send actions until we run out of things to send,
220
	// or have to wait more than 15s before sending again,
221
	// or we hit a lock or some other sending issue
222
	static function do_cron_sync() {
223
		if ( ! self::sync_allowed() ) {
224
			return;
225
		}
226
227
		self::initialize_sender();
228
229
		$time_limit = Jetpack_Sync_Settings::get_setting( 'cron_sync_time_limit' );
230
		$start_time = time();
231
232
		do {
233
			$next_sync_time = self::$sender->get_next_sync_time( 'sync' );
234
235
			if ( $next_sync_time ) {
236
				$delay = $next_sync_time - time() + 1;
237
				if ( $delay > 15 ) {
238
					break;
239
				} elseif ( $delay > 0 ) {
240
					sleep( $delay );
241
				}
242
			}
243
244
			$result = self::$sender->do_sync();
245
		} while ( $result && ( $start_time + $time_limit ) > time() );
246
	}
247
248
	static function do_cron_full_sync() {
249
		if ( ! self::sync_allowed() ) {
@@ 248-272 (lines=25) @@
245
		} while ( $result && ( $start_time + $time_limit ) > time() );
246
	}
247
248
	static function do_cron_full_sync() {
249
		if ( ! self::sync_allowed() ) {
250
			return;
251
		}
252
253
		self::initialize_sender();
254
255
		$time_limit = Jetpack_Sync_Settings::get_setting( 'cron_sync_time_limit' );
256
		$start_time = time();
257
258
		do {
259
			$next_sync_time = self::$sender->get_next_sync_time( 'full_sync' );
260
261
			if ( $next_sync_time ) {
262
				$delay = $next_sync_time - time() + 1;
263
				if ( $delay > 15 ) {
264
					break;
265
				} elseif ( $delay > 0 ) {
266
					sleep( $delay );
267
				}
268
			}
269
270
			$result = self::$sender->do_full_sync();
271
		} while ( $result && ( $start_time + $time_limit ) > time() );
272
	}
273
274
	static function initialize_listener() {
275
		require_once dirname( __FILE__ ) . '/class.jetpack-sync-listener.php';