Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ DedicatedThreadScheduler GitScheduler {

TaskFactory DedicatedOperationFactory {
get {
if (rootRepository == null)
throw new ObjectDisposedException ("This object is disposed.");
if (dedicatedOperationFactory == null)
dedicatedOperationFactory = new TaskFactory (GitScheduler);
return dedicatedOperationFactory;
Expand Down Expand Up @@ -285,6 +287,7 @@ void ThawEvents ()
FileService.ThawEvents ();
}

object repositoryDisposeLock = new object ();
protected override void Dispose (bool disposing)
{
if (IsDisposed)
Expand All @@ -296,20 +299,24 @@ protected override void Dispose (bool disposing)
gitLock?.Dispose ();
if (rootRepository != null) {
DedicatedOperationFactory.StartNew (() => {
try {
rootRepository?.Dispose ();
} catch (Exception e) {
LoggingService.LogInternalError ("Disposing LibGit2Sharp.Repository failed", e);
}
if (cachedSubmodules != null) {
foreach (var submodule in cachedSubmodules) {
if (submodule?.Item2 != null) {
try {
submodule?.Item2.Dispose ();
} catch (Exception e) {
LoggingService.LogInternalError ("Disposing LibGit2Sharp.Repository failed", e);
lock (repositoryDisposeLock) {
try {
rootRepository?.Dispose ();
rootRepository = null;
} catch (Exception e) {
LoggingService.LogInternalError ("Disposing LibGit2Sharp.Repository failed", e);
}
if (cachedSubmodules != null) {
foreach (var submodule in cachedSubmodules) {
if (submodule?.Item2 != null) {
try {
submodule?.Item2.Dispose ();
} catch (Exception e) {
LoggingService.LogInternalError ("Disposing LibGit2Sharp.Repository failed", e);
}
}
}
cachedSubmodules = null;
}
}
}).Wait ();
Expand All @@ -322,8 +329,6 @@ protected override void Dispose (bool disposing)
base.Dispose (disposing);

watcher = null;
rootRepository = null;
cachedSubmodules = null;
}

public override string[] SupportedProtocols {
Expand Down