Skip to content

Commit

Permalink
add a lock instead of an init queue to the restore() operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
scbedd committed May 8, 2024
1 parent 7cd07c4 commit 31b4772
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

This comment has been minimized.

Copy link
@scbedd

scbedd May 8, 2024

Author Member

I can't recall the git config, but for some, the .git is a file not a folder.

}
}
}
11 changes: 5 additions & 6 deletions tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -511,16 +512,14 @@ public static string GetCloneUrl(string assetsRepo, string repositoryLocation, b
/// <param name="config"></param>
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.

This comment has been minimized.

Copy link
@scbedd

scbedd May 8, 2024

Author Member

My original thought of queuing these should be solid, but trying this to see if it helps with the issues that .NET is seeing.

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()))
Expand Down

0 comments on commit 31b4772

Please sign in to comment.