Make number of jobs configurable, fix bug in IndexedFile query

This commit is contained in:
Timothy Baldridge 2020-01-30 16:39:14 -07:00
parent d8e8efc404
commit a8c48527f7
3 changed files with 14 additions and 8 deletions

View File

@ -22,5 +22,7 @@ namespace Wabbajack.BuildServer
public string BunnyCDN_Password { get; set; } public string BunnyCDN_Password { get; set; }
public string SqlConnection { get; set; } public string SqlConnection { get; set; }
public int MaxJobs { get; set; } = 2;
} }
} }

View File

@ -32,7 +32,7 @@ namespace Wabbajack.BuildServer
public void StartJobRunners() public void StartJobRunners()
{ {
if (!Settings.JobRunner) return; if (!Settings.JobRunner) return;
for (var idx = 0; idx < 2; idx++) for (var idx = 0; idx < Settings.MaxJobs; idx++)
{ {
Task.Run(async () => Task.Run(async () =>
{ {

View File

@ -107,7 +107,7 @@ namespace Wabbajack.BuildServer.Model.Models
{ {
await using var conn = await Open(); await using var conn = await Open();
var files = await conn.QueryAsync<ArchiveContentsResult>(@" var files = await conn.QueryAsync<ArchiveContentsResult>(@"
SELECT 0 as Parent, i.Hash, i.Size, null as Path FROM IndexedFile WHERE Hash = @Hash SELECT 0 as Parent, i.Hash, i.Size, null as Path FROM IndexedFile i WHERE Hash = @Hash
UNION ALL UNION ALL
SELECT a.Parent, i.Hash, i.Size, a.Path FROM AllArchiveContent a SELECT a.Parent, i.Hash, i.Size, a.Path FROM AllArchiveContent a
LEFT JOIN IndexedFile i ON i.Hash = a.Child LEFT JOIN IndexedFile i ON i.Hash = a.Child
@ -118,13 +118,17 @@ namespace Wabbajack.BuildServer.Model.Models
List<IndexedVirtualFile> Build(long parent) List<IndexedVirtualFile> Build(long parent)
{ {
return grouped[parent].Select(f => new IndexedVirtualFile if (grouped.TryGetValue(parent, out var children))
{ {
Name = f.Path, return children.Select(f => new IndexedVirtualFile
Hash = BitConverter.GetBytes(f.Hash).ToBase64(), {
Size = f.Size, Name = f.Path,
Children = Build(f.Hash) Hash = BitConverter.GetBytes(f.Hash).ToBase64(),
}).ToList(); Size = f.Size,
Children = Build(f.Hash)
}).ToList();
}
return new List<IndexedVirtualFile>();
} }
return Build(0).First(); return Build(0).First();
} }