bool PlatformLauncher::shouldAutoUpdate()

in src/main/cpp/bootstrap/platformlauncher.cpp [431:498]


bool PlatformLauncher::shouldAutoUpdate(bool firstStart, const char *basePath) {
    // The logic is following:
    // if there is an NBM for installation then run updater
    // unless it is not a first start and we asked to install later (on next start)

    // then also check if last run left list of modules to disable/uninstall and
    // did not mark them to be deactivated later (on next start)
    string path = basePath;
    path += "\\update\\download\\*.nbm";
    logMsg("Checking for updates: %s", path.c_str());
    WIN32_FIND_DATA fd;
    HANDLE hFindNbms = FindFirstFile(path.c_str(), &fd);
    if (hFindNbms != INVALID_HANDLE_VALUE) {
        logMsg("Some updates found at %s", path.c_str());
        FindClose(hFindNbms);
    } else {
        //also check for OSGi jars if *.nbm not found
        path = basePath;
        path += "\\update\\download\\*.jar";
        hFindNbms = FindFirstFile(path.c_str(), &fd);
        if (hFindNbms != INVALID_HANDLE_VALUE) {
            logMsg("Some OSGi updates found at %s", path.c_str());
            FindClose(hFindNbms);
        }
    }

    path = basePath;
    path += "\\update\\download\\install_later.xml";
    HANDLE hFind = FindFirstFile(path.c_str(), &fd);
    if (hFind != INVALID_HANDLE_VALUE) {
        logMsg("install_later.xml found: %s", path.c_str());
        FindClose(hFind);
    }

    if (hFindNbms != INVALID_HANDLE_VALUE && (firstStart || hFind == INVALID_HANDLE_VALUE)) {
        return true;
    }

    path = basePath;
    path += "\\update\\deactivate\\deactivate_later.txt";
    hFind = FindFirstFile(path.c_str(), &fd);
    if (hFind != INVALID_HANDLE_VALUE) {
        logMsg("deactivate_later.txt found: %s", path.c_str());
        FindClose(hFind);
    }

    if (firstStart || hFind == INVALID_HANDLE_VALUE) {
        path = basePath;
        path += "\\update\\deactivate\\to_disable.txt";
        hFind = FindFirstFile(path.c_str(), &fd);
        if (hFind != INVALID_HANDLE_VALUE) {
            logMsg("to_disable.txt found: %s", path.c_str());
            FindClose(hFind);
            return true;
        }

        path = basePath;
        path += "\\update\\deactivate\\to_uninstall.txt";
        hFind = FindFirstFile(path.c_str(), &fd);
        if (hFind != INVALID_HANDLE_VALUE) {
            logMsg("to_uninstall.txt found: %s", path.c_str());
            FindClose(hFind);
            return true;
        }
    }

    return false;
}