Repository: bitcoin/bitcoin
File: src/init.cpp (C++)

Code before:
#ifdef __APPLE__
    // Warn about exFAT filesystem usage on macOS
    std::vector<std::string> exfat_paths;
    std::vector<std::string> error_paths;

    auto check_fs = [&](const fs::path& path, std::string_view desc) {
        FSType fs_type = GetFilesystemType(path);
        std::string path_desc = strprintf("%s (\"%s\")", desc, fs::PathToString(path));
        if (fs_type == FSType::EXFAT) {
            exfat_paths.push_back(path_desc);
        } else if (fs_type == FSType::ERROR) {
            error_paths.push_back(path_desc);
        }
    };

    check_fs(args.GetDataDirNet(), "data directory");
    check_fs(args.GetBlocksDirPath(), "blocks directory");

    if (!exfat_paths.empty()) {
        InitWarning(strprintf(_("The following paths are on exFAT which is known to have intermittent corruption problems on macOS: %s. "
            "Move these directories to a non-exFAT formatted drive to avoid corruption."),
            util::Join(exfat_paths, ", ")));
    }

    if (!error_paths.empty()) {
        LogInfo("Failed to detect filesystem type for: %s\n", util::Join(error_paths, ", "));
    }
#endif

#if HAVE_SYSTEM
    const std::string block_notify = args.GetArg("-blocknotify", "");
    if (!block_notify.empty()) {
        uiInterface.NotifyBlockTip_connect([block_notify](SynchronizationState sync_state, const CBlockIndex& block, double /* verification_progress */) {
            if (sync_state != SynchronizationState::POST_INIT) return;
            std::string command = block_notify;
            ReplaceAll(command, "%s", block.GetBlockHash().GetHex());
            std::thread t(runCommand, command);
            t.detach(); // thread runs free
        });
    }
#endif

    std::vector<fs::path> vImportFiles;
    for (const std::string& strFile : args.GetArgs("-loadblock")) {
        vImportFiles.push_back(fs::PathFromString(strFile));
    }

    node.background_init_thread = std::thread(&util::TraceThread, "initload", [=, &chainman, &args, &node] {
        ScheduleBatchPriority();
        // Import blocks and ActivateBestChain()
        ImportBlocks(chainman, vImportFiles);

Review comment (bug):
```suggestion
        LogInfo("Failed to detect filesystem type for: %s", util::Join(error_paths, ", "));
```

nit: no need for newline in new code

Code after:
        InitError(strprintf(_("Error: Disk space is low for %s"), fs::quoted(fs::PathToString(args.GetBlocksDirPath()))));
        return false;
    }

    int chain_active_height = WITH_LOCK(cs_main, return chainman.ActiveChain().Height());

    // On first startup, warn on low block storage space
    if (!do_reindex && !do_reindex_chainstate && chain_active_height <= 1) {
        uint64_t assumed_chain_bytes{chainparams.AssumedBlockchainSize() * 1024 * 1024 * 1024};
        uint64_t additional_bytes_needed{
            chainman.m_blockman.IsPruneMode() ?
                std::min(chainman.m_blockman.GetPruneTarget(), assumed_chain_bytes) :
                assumed_chain_bytes};

        if (!CheckDiskSpace(args.GetBlocksDirPath(), additional_bytes_needed)) {
            InitWarning(strprintf(_(
                    "Disk space for %s may not accommodate the block files. " \
                    "Approximately %u GB of data will be stored in this directory."
                ),
                fs::quoted(fs::PathToString(args.GetBlocksDirPath())),
                chainparams.AssumedBlockchainSize()
            ));
        }
    }

#ifdef __APPLE__
    auto check_and_warn_fs{[&](const fs::path& path, std::string_view desc) {
        const auto path_desc{strprintf("%s (\"%s\")", desc, fs::PathToString(path))};
        switch (GetFilesystemType(path)) {
        case FSType::EXFAT:
            InitWarning(strprintf(_("The %s path uses exFAT, which is known to have intermittent corruption problems on macOS. "
                "Move this directory to a different filesystem to avoid data loss."), path_desc));
            break;
        case FSType::ERROR:
            LogInfo("Failed to detect filesystem type for %s", path_desc);
            break;
        case FSType::OTHER:
            break;
        }
    }};

    check_and_warn_fs(args.GetDataDirNet(), "data directory");
    check_and_warn_fs(args.GetBlocksDirPath(), "blocks directory");
#endif

#if HAVE_SYSTEM
    const std::string block_notify = args.GetArg("-blocknotify", "");
    if (!block_notify.empty()) {
        uiInterface.NotifyBlockTip_connect([block_notify](SynchronizationState sync_state, const CBlockIndex& block, double /* verification_progress */) {
            if (sync_state != SynchronizationState::POST_INIT) return;
            std::string command = block_notify;