Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions GVFS/GVFS.Common/GVFSConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public static class GitConfig
public const string TrustPackIndexes = GVFSPrefix + "trust-pack-indexes";
public const bool TrustPackIndexesDefault = true;

/* Kill switch for the destructive part of packfile-maintenance corruption recovery: when
* false, GVFS still detects and reports corrupt packs but does not delete them (or later
* prefetch packs) and does not request a restoring prefetch. Detection/telemetry is
* unaffected; the non-destructive multi-pack-index rewrite still runs. */
public const string EnablePackfileRecovery = GVFSPrefix + "enable-packfile-recovery";
public const bool EnablePackfileRecoveryDefault = true;

public const string ShowHydrationStatus = GVFSPrefix + "show-hydration-status";
public const bool ShowHydrationStatusDefault = false;

Expand Down
11 changes: 11 additions & 0 deletions GVFS/GVFS.Common/Git/GitProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,17 @@ public Result VerifyMultiPackIndex(string objectDir)
return this.InvokeGitAgainstDotGitFolder("-c core.multiPackIndex=true multi-pack-index verify --object-dir=\"" + objectDir + "\" --no-progress");
}

/// <summary>
/// Verifies the integrity of a single packfile via its .idx. Returns a failure exit code if the
/// pack is truncated or otherwise unreadable. Used by pack maintenance recovery to determine
/// which pack is corrupt - the "could not load pack N" ordinal reported by the multi-pack-index
/// is an internal position, not a filename, so it cannot be mapped to a file directly.
/// </summary>
public Result VerifyPack(string packIndexPath)
{
return this.InvokeGitAgainstDotGitFolder("verify-pack \"" + packIndexPath + "\"");
Comment thread
tyrielv marked this conversation as resolved.
}

public Result RemoteAdd(string remoteName, string url)
{
return this.InvokeGitAgainstDotGitFolder("remote add " + remoteName + " " + url);
Expand Down
14 changes: 12 additions & 2 deletions GVFS/GVFS.Common/Maintenance/GitMaintenanceScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ private void ScheduleRecurringSteps()
return;
}

if (this.gitObjects.IsUsingCacheServer())
bool usingCacheServer = this.gitObjects.IsUsingCacheServer();

if (usingCacheServer)
{
TimeSpan prefetchPeriod = TimeSpan.FromMinutes(15);
this.stepTimers.Add(new Timer(
Expand All @@ -70,8 +72,16 @@ private void ScheduleRecurringSteps()
dueTime: this.looseObjectsDueTime,
period: this.looseObjectsPeriod));

// When packfile-maintenance recovery removes a corrupt prefetch pack (and the later prefetch
// packs that depend on it), it needs a prefetch to re-download them and rebuild the
// commit-graph. This is only meaningful when a cache server is in use; otherwise the objects
// are restored on demand.
Action requestPrefetch = usingCacheServer
? () => this.queue.TryEnqueue(new PrefetchStep(this.context, this.gitObjects))
: (Action)null;

this.stepTimers.Add(new Timer(
(state) => this.queue.TryEnqueue(new PackfileMaintenanceStep(this.context)),
(state) => this.queue.TryEnqueue(new PackfileMaintenanceStep(this.context, requestPrefetch: requestPrefetch)),
state: null,
dueTime: this.packfileDueTime,
period: this.packfilePeriod));
Expand Down
Loading
Loading