Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions include/vcpkg/binarycaching.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <vcpkg/fwd/dependencies.h>
#include <vcpkg/fwd/vcpkgpaths.h>

#include <vcpkg/base/chrono.h>
#include <vcpkg/base/downloads.h>
#include <vcpkg/base/expected.h>
#include <vcpkg/base/files.h>
Expand Down Expand Up @@ -119,9 +120,18 @@ namespace vcpkg
/// Returns a vector where each index corresponds to the matching index in `actions`.
std::vector<CacheAvailability> precheck(const VcpkgPaths& paths, View<Dependencies::InstallPlanAction> actions);

/// Sets the time in seconds from now after which "unavailable" entries will be checked again.
/// A non-positive value disables re-checking.
void set_ttl_for_unavailable(int seconds);

private:
/// Returns true when the lifetime for "unvailable" entries is exceeded.
bool must_recheck_unavailable_entries() const noexcept;

std::unordered_map<std::string, CacheStatus> m_status;
std::vector<std::unique_ptr<IBinaryProvider>> m_providers;
ElapsedTimer m_ttl_elapsed;
int m_ttl_for_unavailable = 0;
};

ExpectedS<Downloads::DownloadManagerConfig> parse_download_configuration(const Optional<std::string>& arg);
Expand Down
16 changes: 15 additions & 1 deletion src/vcpkg/binarycaching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,20 @@ namespace vcpkg
}
}

void BinaryCache::set_ttl_for_unavailable(int seconds)
{
m_ttl_for_unavailable = seconds;
if (seconds > 0)
{
m_ttl_elapsed = ElapsedTimer::create_started();
}
}

bool BinaryCache::must_recheck_unavailable_entries() const noexcept
{
return m_ttl_for_unavailable > 0 && m_ttl_elapsed.elapsed().as<std::chrono::seconds>().count() > m_ttl_for_unavailable;
}

RestoreResult BinaryCache::try_restore(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action)
{
const auto abi = action.package_abi().get();
Expand Down Expand Up @@ -1182,7 +1196,7 @@ namespace vcpkg
continue; // this one already tried :)
}

if (cache_status.is_unavailable(m_providers.size()))
if (cache_status.is_unavailable(m_providers.size()) && !must_recheck_unavailable_entries())
{
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/vcpkg/commands.ci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ namespace vcpkg::Commands::CI
StatusParagraphs status_db = database_load_check(paths);

auto collection_timer = ElapsedTimer::create_started();
binary_cache.set_ttl_for_unavailable(120);
auto summary = Install::perform(args,
action_plan,
Install::KeepGoing::YES,
Expand Down