Skip to content

Commit

Permalink
Remove git object code that was only used for hydrating files
Browse files Browse the repository at this point in the history
  • Loading branch information
wilbaker committed Aug 9, 2019
1 parent 5d9a0f2 commit feca158
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 128 deletions.
57 changes: 0 additions & 57 deletions GVFS/GVFS.Common/Git/GVFSGitObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,63 +33,6 @@ public enum RequestSource

protected GVFSContext Context { get; private set; }

public virtual bool TryCopyBlobContentStream(
string sha,
CancellationToken cancellationToken,
RequestSource requestSource,
Action<Stream, long> writeAction)
{
RetryWrapper<bool> retrier = new RetryWrapper<bool>(this.GitObjectRequestor.RetryConfig.MaxAttempts, cancellationToken);
retrier.OnFailure +=
errorArgs =>
{
EventMetadata metadata = new EventMetadata();
metadata.Add("sha", sha);
metadata.Add("AttemptNumber", errorArgs.TryCount);
metadata.Add("WillRetry", errorArgs.WillRetry);
if (errorArgs.Error != null)
{
metadata.Add("Exception", errorArgs.Error.ToString());
}
string message = "TryCopyBlobContentStream: Failed to provide blob contents";
if (errorArgs.WillRetry)
{
this.Tracer.RelatedWarning(metadata, message, Keywords.Telemetry);
}
else
{
this.Tracer.RelatedError(metadata, message);
}
};

RetryWrapper<bool>.InvocationResult invokeResult = retrier.Invoke(
tryCount =>
{
bool success = this.Context.Repository.TryCopyBlobContentStream(sha, writeAction);
if (success)
{
return new RetryWrapper<bool>.CallbackResult(true);
}
else
{
// Pass in false for retryOnFailure because the retrier in this method manages multiple attempts
if (this.TryDownloadAndSaveObject(sha, cancellationToken, requestSource, retryOnFailure: false) == DownloadAndSaveObjectResult.Success)
{
if (this.Context.Repository.TryCopyBlobContentStream(sha, writeAction))
{
return new RetryWrapper<bool>.CallbackResult(true);
}
}
return new RetryWrapper<bool>.CallbackResult(error: null, shouldRetry: true);
}
});

return invokeResult.Result;
}

public DownloadAndSaveObjectResult TryDownloadAndSaveObject(string objectId, RequestSource requestSource)
{
return this.TryDownloadAndSaveObject(objectId, CancellationToken.None, requestSource, retryOnFailure: true);
Expand Down
21 changes: 0 additions & 21 deletions GVFS/GVFS.Common/Git/GitRepo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,6 @@ public bool TryGetIsBlob(string sha, out bool isBlob)
return this.libgit2RepoInvoker.TryInvoke(repo => repo.IsBlob(sha), out isBlob);
}

public virtual bool TryCopyBlobContentStream(string blobSha, Action<Stream, long> writeAction)
{
LooseBlobState state = this.GetLooseBlobState(blobSha, writeAction, out long size);

if (state == LooseBlobState.Exists)
{
return true;
}
else if (state != LooseBlobState.Missing)
{
return false;
}

if (!this.libgit2RepoInvoker.TryInvoke(repo => repo.TryCopyBlob(blobSha, writeAction), out bool copyBlobResult))
{
return false;
}

return copyBlobResult;
}

public virtual bool CommitAndRootTreeExists(string commitSha)
{
bool output = false;
Expand Down
31 changes: 0 additions & 31 deletions GVFS/GVFS.UnitTests/Git/GVFSGitObjectsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,6 @@ public class GVFSGitObjectsTests
private const string TestLocalCacheRoot = "mock:\\.gvfs";
private const string TestObjectRoot = "mock:\\.gvfs\\gitObjectCache";

[TestCase]
[Category(CategoryConstants.ExceptionExpected)]
public void CatchesFileNotFoundAfterFileDeleted()
{
MockFileSystemWithCallbacks fileSystem = new MockFileSystemWithCallbacks();
fileSystem.OnFileExists = () => true;
fileSystem.OnOpenFileStream = (path, fileMode, fileAccess) =>
{
if (fileAccess == FileAccess.Write)
{
return new MemoryStream();
}
throw new FileNotFoundException();
};

MockHttpGitObjects httpObjects = new MockHttpGitObjects();
using (httpObjects.InputStream = new MemoryStream(System.Text.Encoding.ASCII.GetBytes(ValidTestObjectFileContents)))
{
httpObjects.MediaType = GVFSConstants.MediaTypes.LooseObjectMediaType;
GVFSGitObjects dut = this.CreateTestableGVFSGitObjects(httpObjects, fileSystem);

dut.TryCopyBlobContentStream(
ValidTestObjectFileContents,
new CancellationToken(),
GVFSGitObjects.RequestSource.FileStreamCallback,
(stream, length) => Assert.Fail("Should not be able to call copy stream callback"))
.ShouldEqual(false);
}
}

[TestCase]
public void SucceedsForNormalLookingLooseObjectDownloads()
{
Expand Down
19 changes: 0 additions & 19 deletions GVFS/GVFS.UnitTests/Mock/Git/MockGVFSGitObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public MockGVFSGitObjects(GVFSContext context, GitObjectsHttpRequestor httpGitOb
this.context = context;
}

public bool CancelTryCopyBlobContentStream { get; set; }
public uint FileLength { get; set; }

public override bool TryDownloadCommit(string objectSha)
Expand All @@ -38,24 +37,6 @@ public override bool TryDownloadCommit(string objectSha)
return result.Succeeded && result.Result.Success;
}

public override bool TryCopyBlobContentStream(
string sha,
CancellationToken cancellationToken,
RequestSource requestSource,
Action<Stream, long> writeAction)
{
if (this.CancelTryCopyBlobContentStream)
{
throw new OperationCanceledException();
}

writeAction(
new MemoryStream(new byte[this.FileLength]),
this.FileLength);

return true;
}

public override string[] ReadPackFileNames(string packFolderPath, string prefixFilter = "")
{
return Array.Empty<string>();
Expand Down

0 comments on commit feca158

Please sign in to comment.