<?php
namespace R2_Offload;

defined( 'ABSPATH' ) || exit;

final class Activator {

	public static function activate(): void {
		DB::install();
		if ( ! wp_next_scheduled( 'r2_offload_cron_tick' ) ) {
			wp_schedule_event( time() + 60, 'hourly', 'r2_offload_cron_tick' );
		}
		wp_mkdir_p( R2_OFFLOAD_DIR . 'logs' );
		if ( ! Installer::vendor_ready() ) {
			Installer::install();
		}
	}

	public static function deactivate(): void {
		$ts = wp_next_scheduled( 'r2_offload_cron_tick' );
		if ( $ts ) {
			wp_unschedule_event( $ts, 'r2_offload_cron_tick' );
		}
	}
}
