Skip to content

Commit 31b4772

Browse files
committed
add a lock instead of an init queue to the restore() operation.
1 parent 7cd07c4 commit 31b4772

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitAssetsConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public bool IsAssetsRepoInitialized(bool autoCreate = true)
127127
{
128128
var location = Path.Join(ResolveAssetRepoLocation().ToString(), ".git");
129129

130-
return Directory.Exists(location);
130+
return Directory.Exists(location) | File.Exists(location);
131131
}
132132
}
133133
}

tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class GitStore : IAssetsStore
4141
public static readonly string GIT_COMMIT_OWNER_ENV_VAR = "GIT_COMMIT_OWNER";
4242
public static readonly string GIT_COMMIT_EMAIL_ENV_VAR = "GIT_COMMIT_EMAIL";
4343
private bool LocalCacheRefreshed = false;
44+
public readonly object LocalCacheLock = new object();
4445

4546
public GitStoreBreadcrumb BreadCrumb = new GitStoreBreadcrumb();
4647

@@ -511,16 +512,14 @@ public static string GetCloneUrl(string assetsRepo, string repositoryLocation, b
511512
/// <param name="config"></param>
512513
public bool IsAssetsRepoInitialized(GitAssetsConfiguration config)
513514
{
514-
// we have to ensure that multiple threads hitting this same segment of code won't stomp on each other
515-
if (!LocalCacheRefreshed)
515+
// we have to ensure that multiple threads hitting this same segment of code won't stomp on each other. restore is incredibly important.
516+
lock (LocalCacheLock)
516517
{
517-
var breadCrumbQueue = InitTasks.GetOrAdd("breadcrumbload", new TaskQueue());
518-
breadCrumbQueue.Enqueue(() =>
518+
if (!LocalCacheRefreshed)
519519
{
520-
521520
BreadCrumb.RefreshLocalCache(Assets, config);
522521
LocalCacheRefreshed = true;
523-
});
522+
}
524523
}
525524

526525
if (Assets.ContainsKey(config.AssetsJsonRelativeLocation.ToString()))

0 commit comments

Comments
 (0)