mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
enhance: skip auto fetching when index.lock
file exists in the repository's git dir
This commit is contained in:
parent
ba9c3058ed
commit
9c6745c271
2 changed files with 10 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -20,6 +21,7 @@ namespace SourceGit.Models
|
|||
|
||||
public class Job
|
||||
{
|
||||
public string IndexLockFile = string.Empty;
|
||||
public Commands.Fetch Cmd = null;
|
||||
public DateTime NextRunTimepoint = DateTime.MinValue;
|
||||
}
|
||||
|
@ -75,8 +77,11 @@ namespace SourceGit.Models
|
|||
|
||||
foreach (var job in uptodate)
|
||||
{
|
||||
job.Cmd.Exec();
|
||||
job.NextRunTimepoint = DateTime.Now.AddMinutes(Convert.ToDouble(Interval));
|
||||
if (!File.Exists(job.IndexLockFile))
|
||||
{
|
||||
job.Cmd.Exec();
|
||||
job.NextRunTimepoint = DateTime.Now.AddMinutes(Convert.ToDouble(Interval));
|
||||
}
|
||||
}
|
||||
|
||||
Thread.Sleep(2000);
|
||||
|
@ -86,10 +91,11 @@ namespace SourceGit.Models
|
|||
});
|
||||
}
|
||||
|
||||
public void AddRepository(string repo)
|
||||
public void AddRepository(string repo, string gitDir)
|
||||
{
|
||||
var job = new Job
|
||||
{
|
||||
IndexLockFile = Path.Combine(gitDir, "index.lock"),
|
||||
Cmd = new Commands.Fetch(repo, "--all", true, false, null) { RaiseError = false },
|
||||
NextRunTimepoint = DateTime.Now.AddMinutes(Convert.ToDouble(Interval)),
|
||||
};
|
||||
|
|
|
@ -271,7 +271,7 @@ namespace SourceGit.ViewModels
|
|||
|
||||
repo.Open();
|
||||
ActiveWorkspace.AddRepository(repo.FullPath);
|
||||
Models.AutoFetchManager.Instance.AddRepository(repo.FullPath);
|
||||
Models.AutoFetchManager.Instance.AddRepository(repo.FullPath, repo.GitDir);
|
||||
|
||||
if (page == null)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue