diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitAssetsConfiguration.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitAssetsConfiguration.cs index dd49da98203..bd814201696 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitAssetsConfiguration.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitAssetsConfiguration.cs @@ -127,7 +127,7 @@ public bool IsAssetsRepoInitialized(bool autoCreate = true) { var location = Path.Join(ResolveAssetRepoLocation().ToString(), ".git"); - return Directory.Exists(location); + return Directory.Exists(location) | File.Exists(location); } } } diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs index 69e0a5dd52f..69dbbfda174 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs @@ -41,6 +41,7 @@ public class GitStore : IAssetsStore public static readonly string GIT_COMMIT_OWNER_ENV_VAR = "GIT_COMMIT_OWNER"; public static readonly string GIT_COMMIT_EMAIL_ENV_VAR = "GIT_COMMIT_EMAIL"; private bool LocalCacheRefreshed = false; + public readonly object LocalCacheLock = new object(); public GitStoreBreadcrumb BreadCrumb = new GitStoreBreadcrumb(); @@ -511,16 +512,14 @@ public static string GetCloneUrl(string assetsRepo, string repositoryLocation, b /// public bool IsAssetsRepoInitialized(GitAssetsConfiguration config) { - // we have to ensure that multiple threads hitting this same segment of code won't stomp on each other - if (!LocalCacheRefreshed) + // we have to ensure that multiple threads hitting this same segment of code won't stomp on each other. restore is incredibly important. + lock (LocalCacheLock) { - var breadCrumbQueue = InitTasks.GetOrAdd("breadcrumbload", new TaskQueue()); - breadCrumbQueue.Enqueue(() => + if (!LocalCacheRefreshed) { - BreadCrumb.RefreshLocalCache(Assets, config); LocalCacheRefreshed = true; - }); + } } if (Assets.ContainsKey(config.AssetsJsonRelativeLocation.ToString()))