bool DependencyAutoLoaderGuard::shouldDiscardFileCompilation()

in prod/native/libcommon/code/DependencyAutoLoaderGuard.cpp [40:76]


bool DependencyAutoLoaderGuard::shouldDiscardFileCompilation(std::string_view fileName) {
    try {
        std::string compiledFilePath = std::filesystem::exists(fileName) ? std::filesystem::canonical(fileName) : fileName;

        if (compiledFilePath.starts_with(vendorPath_)) {
            return false;
        }

        auto [lastClass, lastFunction] = bridge_->getNewlyCompiledFiles(
            [this](std::string_view name) {
                // storing only dependencies delivered by EDOT
                if (name.starts_with(vendorPath_)) {
                    if (name.substr(vendorPath_.length()).starts_with("/composer/")) { // skip compsoer files - they must be compiled
                        ELOGF_TRACE(logger_, DEPGUARD, "Skipping storage of composer files: " PRsv, PRsvArg(name));
                        return;
                    }
                    compiledFiles_.insert(name);
                    ELOGF_TRACE(logger_, DEPGUARD, "Storing file: " PRsv, PRsvArg(name));
                }
            },
            lastClass_, lastFunction_);

        lastClass_ = lastClass;
        lastFunction_ = lastFunction;

        if (wasDeliveredByEDOT(compiledFilePath)) {
            ELOGF_DEBUG(logger_, DEPGUARD, "Compilation of file '" PRsv "' will be discarded", PRsvArg(compiledFilePath));
            return true;
        }

    } catch (std::exception const &e) {
        ELOGF_WARNING(logger_, DEPGUARD, "shouldDiscardFileCompilation of file '" PRsv "' throwed: %s", PRsvArg(fileName), e.what());
        return false;
    }

    return false;
}