Code Duplication    Length = 25-25 lines in 2 locations

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

@@ 293-317 (lines=25) @@
290
	// try to send actions until we run out of things to send,
291
	// or have to wait more than 15s before sending again,
292
	// or we hit a lock or some other sending issue
293
	static function do_cron_sync() {
294
		if ( ! self::sync_allowed() ) {
295
			return;
296
		}
297
298
		self::initialize_sender();
299
300
		$time_limit = Jetpack_Sync_Settings::get_setting( 'cron_sync_time_limit' );
301
		$start_time = time();
302
303
		do {
304
			$next_sync_time = self::$sender->get_next_sync_time( 'sync' );
305
306
			if ( $next_sync_time ) {
307
				$delay = $next_sync_time - time() + 1;
308
				if ( $delay > 15 ) {
309
					break;
310
				} elseif ( $delay > 0 ) {
311
					sleep( $delay );
312
				}
313
			}
314
315
			$result = self::$sender->do_sync();
316
		} while ( $result && ( $start_time + $time_limit ) > time() );
317
	}
318
319
	static function do_cron_full_sync() {
320
		if ( ! self::sync_allowed() ) {
@@ 319-343 (lines=25) @@
316
		} while ( $result && ( $start_time + $time_limit ) > time() );
317
	}
318
319
	static function do_cron_full_sync() {
320
		if ( ! self::sync_allowed() ) {
321
			return;
322
		}
323
324
		self::initialize_sender();
325
326
		$time_limit = Jetpack_Sync_Settings::get_setting( 'cron_sync_time_limit' );
327
		$start_time = time();
328
329
		do {
330
			$next_sync_time = self::$sender->get_next_sync_time( 'full_sync' );
331
332
			if ( $next_sync_time ) {
333
				$delay = $next_sync_time - time() + 1;
334
				if ( $delay > 15 ) {
335
					break;
336
				} elseif ( $delay > 0 ) {
337
					sleep( $delay );
338
				}
339
			}
340
341
			$result = self::$sender->do_full_sync();
342
		} while ( $result && ( $start_time + $time_limit ) > time() );
343
	}
344
345
	static function initialize_listener() {
346
		require_once dirname( __FILE__ ) . '/class.jetpack-sync-listener.php';