Code Duplication    Length = 25-25 lines in 2 locations

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

@@ 318-342 (lines=25) @@
315
	// try to send actions until we run out of things to send,
316
	// or have to wait more than 15s before sending again,
317
	// or we hit a lock or some other sending issue
318
	static function do_cron_sync() {
319
		if ( ! self::sync_allowed() ) {
320
			return;
321
		}
322
323
		self::initialize_sender();
324
325
		$time_limit = Jetpack_Sync_Settings::get_setting( 'cron_sync_time_limit' );
326
		$start_time = time();
327
328
		do {
329
			$next_sync_time = self::$sender->get_next_sync_time( 'sync' );
330
331
			if ( $next_sync_time ) {
332
				$delay = $next_sync_time - time() + 1;
333
				if ( $delay > 15 ) {
334
					break;
335
				} elseif ( $delay > 0 ) {
336
					sleep( $delay );
337
				}
338
			}
339
340
			$result = self::$sender->do_sync();
341
		} while ( $result && ( $start_time + $time_limit ) > time() );
342
	}
343
344
	static function do_cron_full_sync() {
345
		if ( ! self::sync_allowed() ) {
@@ 344-368 (lines=25) @@
341
		} while ( $result && ( $start_time + $time_limit ) > time() );
342
	}
343
344
	static function do_cron_full_sync() {
345
		if ( ! self::sync_allowed() ) {
346
			return;
347
		}
348
349
		self::initialize_sender();
350
351
		$time_limit = Jetpack_Sync_Settings::get_setting( 'cron_sync_time_limit' );
352
		$start_time = time();
353
354
		do {
355
			$next_sync_time = self::$sender->get_next_sync_time( 'full_sync' );
356
357
			if ( $next_sync_time ) {
358
				$delay = $next_sync_time - time() + 1;
359
				if ( $delay > 15 ) {
360
					break;
361
				} elseif ( $delay > 0 ) {
362
					sleep( $delay );
363
				}
364
			}
365
366
			$result = self::$sender->do_full_sync();
367
		} while ( $result && ( $start_time + $time_limit ) > time() );
368
	}
369
370
	static function initialize_listener() {
371
		require_once dirname( __FILE__ ) . '/class.jetpack-sync-listener.php';