Skip to content

Commit

Permalink
Skip updating disabled mods
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Dec 31, 2021
1 parent 90dff2e commit 07bfbc9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/KKManager.Core/Data/Cards/Card.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace KKManager.Data.Cards
{
public abstract class Card : IFileInfoBase
{
public virtual string Name => Path.GetFileNameWithoutExtension(Location.Name);
public virtual string Name => Location.GetNameWithoutExtension();
[DisplayName("Filename")]
public FileInfo Location { get; }
public CardType Type { get; }
Expand Down
6 changes: 6 additions & 0 deletions src/KKManager.Core/Util/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,11 @@ public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TS
}
}
}

public static string GetNameWithoutExtension(this FileSystemInfo fsi)
{
if (fsi == null) throw new ArgumentNullException(nameof(fsi));
return Path.GetFileNameWithoutExtension(fsi.Name);
}
}
}
8 changes: 8 additions & 0 deletions src/KKManager.Updater/KKManager.Updater.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System.Reactive, Version=4.4.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reactive.4.4.1\lib\net46\System.Reactive.dll</HintPath>
</Reference>
<Reference Include="System.Reflection.Metadata, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reflection.Metadata.5.0.0\lib\net461\System.Reflection.Metadata.dll</HintPath>
</Reference>
Expand All @@ -123,11 +126,16 @@
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Windows" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml.Serialization" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Downloader\DownloadSourceCrashedException.cs" />
Expand Down
11 changes: 8 additions & 3 deletions src/KKManager.Updater/UpdateSourceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
using System.IO;
using System.Linq;
using System.Net;
using System.Reactive.Linq;
using System.Threading;
using System.Threading.Tasks;
using KKManager.Data.Zipmods;
using KKManager.Updater.Data;
using KKManager.Updater.Properties;
using KKManager.Updater.Sources;
Expand Down Expand Up @@ -46,7 +48,9 @@ private static async Task<List<UpdateTask>> GetUpdatesInt(CancellationToken canc
var results = new ConcurrentBag<UpdateTask>();

var ignoreListPath = "ignorelist.txt";
var ignoreList = File.Exists(ignoreListPath) ? File.ReadAllLines(ignoreListPath) : new string[0];
var ignoreList = File.Exists(ignoreListPath) ? File.ReadAllLines(ignoreListPath).ToList() : new List<string>();
// Skip updating disabled mods
ignoreList.AddRange(SideloaderModLoader.Zipmods.ToEnumerable().Where(x => !x.Enabled).Select(x => x.Location.GetNameWithoutExtension()));

var anySuccessful = false;

Expand All @@ -71,8 +75,9 @@ private static async Task<List<UpdateTask>> GetUpdatesInt(CancellationToken canc
!filterByGuids.Contains(task.Info.GUID))
continue;
task.Items.RemoveAll(x =>
x.UpToDate || (x.RemoteFile != null && ignoreList.Any(x.RemoteFile.Name.Contains)));
task.Items.RemoveAll(x => x.UpToDate ||
// Todo disable updating by default instead whenever that's done
(x.RemoteFile != null && ignoreList.Any(x.RemoteFile.Name.Contains)) || (x.TargetPath != null && ignoreList.Any(x.TargetPath.GetNameWithoutExtension().Contains)));
results.Add(task);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/KKManager.Updater/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
<package id="System.Collections.Immutable" version="5.0.0" targetFramework="net462" />
<package id="System.Memory" version="4.5.4" targetFramework="net462" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net462" />
<package id="System.Reactive" version="4.4.1" targetFramework="net462" />
<package id="System.Reflection.Emit" version="4.7.0" targetFramework="net462" />
<package id="System.Reflection.Emit.Lightweight" version="4.7.0" targetFramework="net462" />
<package id="System.Reflection.Metadata" version="5.0.0" targetFramework="net462" />
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net462" />
<package id="System.Runtime.Serialization.Primitives" version="4.3.0" targetFramework="net462" />
<package id="System.Text.Encoding.CodePages" version="5.0.0" targetFramework="net462" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net462" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net462" />
<package id="Windows7APICodePack-Core" version="1.1.0.0" targetFramework="net462" />
<package id="Windows7APICodePack-Shell" version="1.1.0.0" targetFramework="net462" />
</packages>

0 comments on commit 07bfbc9

Please sign in to comment.