Skip to content
Merged
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
15 changes: 14 additions & 1 deletion GVFS/GVFS.Common/Maintenance/PrefetchStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class PrefetchStep : GitMaintenanceStep
private const int LockWaitTimeMs = 100;
private const int WaitingOnLockLogThreshold = 50;
private const string PrefetchCommitsAndTreesLock = "prefetch-commits-trees.lock";
private const int NoExistingPrefetchPacks = -1;
private readonly TimeSpan timeBetweenPrefetches = TimeSpan.FromMinutes(70);

public PrefetchStep(GVFSContext context, GitObjects gitObjects, bool requireCacheLock = true)
Expand Down Expand Up @@ -80,6 +81,18 @@ protected override void PerformMaintenance()
return;
}

if (last == NoExistingPrefetchPacks)
{
/* If there are no existing prefetch packs, that means that either the
* first prefetch is still in progress or the clone was run with "--no-prefetch".
* In either case, we should not run prefetch as a maintenance task.
* If users want to prefetch after cloning with "--no-prefetch", they can run
* "gvfs prefetch" manually. Also, "git pull" and "git fetch" will run prefetch
* as a pre-command hook. */
this.Context.Tracer.RelatedInfo(this.Area + ": Skipping prefetch since there are no existing prefetch packs");
return;
}

DateTime lastDateTime = EpochConverter.FromUnixEpochSeconds(last);
DateTime now = DateTime.UtcNow;

Expand Down Expand Up @@ -150,7 +163,7 @@ private bool TryGetMaxGoodPrefetchTimestamp(out long maxGoodTimestamp, out strin
.OrderBy(packInfo => packInfo.Timestamp)
.ToList();

maxGoodTimestamp = -1;
maxGoodTimestamp = NoExistingPrefetchPacks;

int firstBadPack = -1;
for (int i = 0; i < orderedPacks.Count; ++i)
Expand Down
Loading