<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
import contextlib
import logging
import os

from defence360agent.contracts.config import ConfigFile, NONE

logger = logging.getLogger(__name__)

# Before DEF-35627 the cron file was defined in MalwareScanSchedule.CRON_PATH and was located here
CRON_PATH = "/etc/cron.d/imunify_scan_schedule"


def _update_config(path=None):
    config = {
        "MALWARE_SCAN_SCHEDULE": {
            "interval": NONE,
        }
    }

    try:
        config_file = ConfigFile(path=path)
        config_file.dict_to_config(config)
    except Exception:
        logger.exception("Failed to set malware scan schedule config")


def _remove_cron(path=CRON_PATH):
    with contextlib.suppress(FileNotFoundError):
        os.unlink(path)


def migrate(migrator, database, fake=False, **kwargs):
    # Stubbed in DEF-11010
    # if fake:
    #     return
    #
    # _update_config()
    # _remove_cron()
    pass


def rollback(migrator, database, fake=False, **kwargs):
    pass
