Informationen ausgelagert Kleines Spy/Test Programm erstellt Mehr Exceptions/InvalidUpdateFileRequestException.cs Launcher Host in Download Server geändert Download Server macht zusätzlich Abfrage an den Hauptserver Download geht jetzt stückweise von statten
86 lines
3.4 KiB
C#
86 lines
3.4 KiB
C#
using BS.SharedLauncher.DataContract;
|
|
using BS.SharedLauncher.Update;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BS.SharedLauncher.Extensions
|
|
{
|
|
public static class PlanerPackageExtension
|
|
{
|
|
public static bool ContainsPlanerFile(this UpdatePlanDC planerPackageInfo, UpdateFileDC file2)
|
|
{
|
|
return planerPackageInfo.Files.FirstOrDefault(file => file.RelativePath == file2.RelativePath) is object;
|
|
}
|
|
public static bool ContainsPlanerFileWithHash(this UpdatePlanDC planerPackageInfo, UpdateFileDC file2)
|
|
{
|
|
return planerPackageInfo.Files.FirstOrDefault(file => file.RelativePath == file2.RelativePath && file.Checksum == file2.Checksum) is object;
|
|
}
|
|
public static bool AnyFile(this UpdatePlanDC planerPackageInfo)
|
|
{
|
|
if (planerPackageInfo.Files is null)
|
|
return false;
|
|
|
|
return planerPackageInfo.Files.Any();
|
|
}
|
|
|
|
public static UpdateFileDC FindPlanerFile(this UpdatePlanDC planerFileInfo, string relative)
|
|
{
|
|
return planerFileInfo.Files.Find(x => x.RelativePath == relative);
|
|
}
|
|
public static UpdateFileDC FirstOrDefaultPlanerFile(this UpdatePlanDC planerFileInfo, string relative)
|
|
{
|
|
return planerFileInfo.Files.FirstOrDefault(x => x.RelativePath == relative);
|
|
}
|
|
public static UpdateFileDC FirstOrDefaultPlanerFile(this UpdatePlanDC planerFileInfo, UpdateFileDC file)
|
|
{
|
|
return planerFileInfo.Files.FirstOrDefault(x => x.EqualsFile(file));
|
|
}
|
|
|
|
public static void InitFiles(this UpdatePlanDC planerFileInfo, List<UpdateFileDC> files)
|
|
{
|
|
planerFileInfo.Files = new List<UpdateFileDC>();
|
|
planerFileInfo.Files.AddRange(files);
|
|
}
|
|
private static void OverrideOrAddFile(this UpdatePlanDC planerFileInfo, UpdateFileDC newFile)
|
|
{
|
|
var oldFile = planerFileInfo.FirstOrDefaultPlanerFile(newFile.RelativePath);
|
|
|
|
if (oldFile is object)
|
|
oldFile.AbsolutePath = newFile.AbsolutePath;
|
|
else
|
|
planerFileInfo.Files.Add(newFile);
|
|
//oldFile.Source = newFile.Source;
|
|
}
|
|
public static void OverrideOrAddFiles(this UpdatePlanDC planerFileInfo, List<UpdateFileDC> files)
|
|
{
|
|
files.ForEach(x => planerFileInfo.OverrideOrAddFile(x));
|
|
}
|
|
public static void TryRemoveFile(this UpdatePlanDC planerFileInfo, UpdateFileDC file)
|
|
{
|
|
var minuend = planerFileInfo.FirstOrDefaultPlanerFile(file);
|
|
|
|
if (minuend is UpdateFileDC)
|
|
{
|
|
planerFileInfo.RemoveFile(minuend);
|
|
}
|
|
}
|
|
public static void RemoveFile(this UpdatePlanDC planerFileInfo, UpdateFileDC file)
|
|
{
|
|
planerFileInfo.Files.Remove(file);
|
|
}
|
|
public static void RemoveFileAt(this UpdatePlanDC planerFileInfo, int index)
|
|
{
|
|
planerFileInfo.Files.RemoveAt(index);
|
|
}
|
|
public static void SubstractFiles(this UpdatePlanDC planerPackageInfo, List<UpdateFileDC> files)
|
|
{
|
|
files.ForEach(f => planerPackageInfo.TryRemoveFile(f));
|
|
}
|
|
|
|
public static void LoadHash(this UpdatePlanDC planer) => planer.Files.ForEach(file => file.LoadHash());
|
|
}
|
|
}
|