Merge branch 'master' into mega-fixes

This commit is contained in:
Timothy Baldridge 2021-07-30 21:29:16 -06:00 committed by GitHub
commit ef156867c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 55 additions and 16 deletions

34
.github/workflows/stale.yml vendored Normal file
View File

@ -0,0 +1,34 @@
# This is a basic workflow to help you get started with Actions
name: Mark Stale
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
schedule:
- cron: "0 0 * * *"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Close Stale Issues
uses: actions/stale@v4.0.0
with:
stale-issue-message: "Marked as stale due to inactivity"
stale-pr-message: "Marked as stale due to inactivity"
close-issue-message: "Closed due to inactivity"
close-pr-message: "Closed due ot inactivity"
days-before-stale: 180
debug-only: false
operations-per-run: 100

View File

@ -4,6 +4,9 @@ on:
push: push:
branches: [ master ] branches: [ master ]
pull_request: pull_request:
paths:
- 'Wabbajack**'
- '.github/workflows/**'
branches: [ master ] branches: [ master ]
jobs: jobs:

View File

@ -350,13 +350,13 @@ namespace Wabbajack.Lib
}); });
*/ */
} }
private static readonly Regex NoDeleteRegex = new(@"(?i)[\\\/]\[NoDelete\]", RegexOptions.Compiled);
/// <summary> /// <summary>
/// The user may already have some files in the OutputFolder. If so we can go through these and /// The user may already have some files in the OutputFolder. If so we can go through these and
/// figure out which need to be updated, deleted, or left alone /// figure out which need to be updated, deleted, or left alone
/// </summary> /// </summary>
public async Task OptimizeModlist() protected async Task OptimizeModlist()
{ {
Utils.Log("Optimizing ModList directives"); Utils.Log("Optimizing ModList directives");
@ -370,7 +370,6 @@ namespace Wabbajack.Lib
var savePath = (RelativePath)"saves"; var savePath = (RelativePath)"saves";
UpdateTracker.NextStep("Looking for files to delete"); UpdateTracker.NextStep("Looking for files to delete");
var regex = new Regex(@"(?i)[\\\/]\[NoDelete\]");
await OutputFolder.EnumerateFiles() await OutputFolder.EnumerateFiles()
.PMap(Queue, UpdateTracker, async f => .PMap(Queue, UpdateTracker, async f =>
{ {
@ -380,7 +379,7 @@ namespace Wabbajack.Lib
if (f.InFolder(profileFolder) && f.Parent.FileName == savePath) return; if (f.InFolder(profileFolder) && f.Parent.FileName == savePath) return;
if (regex.IsMatch(f.ToString())) if (NoDeleteRegex.IsMatch(f.ToString()))
return; return;
Utils.Log($"Deleting {relativeTo} it's not part of this ModList"); Utils.Log($"Deleting {relativeTo} it's not part of this ModList");

View File

@ -14,7 +14,7 @@ namespace Wabbajack.Lib.CompilationSteps
{ {
_pattern = pattern; _pattern = pattern;
_reason = $"Ignored because path matches regex {pattern}"; _reason = $"Ignored because path matches regex {pattern}";
_regex = new Regex(pattern); _regex = new Regex(pattern, RegexOptions.Compiled);
} }
public override async ValueTask<Directive?> Run(RawSourceFile source) public override async ValueTask<Directive?> Run(RawSourceFile source)

View File

@ -13,7 +13,7 @@ namespace Wabbajack.Lib.CompilationSteps
public IncludeRegex(ACompiler compiler, string pattern) : base(compiler) public IncludeRegex(ACompiler compiler, string pattern) : base(compiler)
{ {
_pattern = pattern; _pattern = pattern;
_regex = new Regex(pattern); _regex = new Regex(pattern, RegexOptions.Compiled);
} }
public override async ValueTask<Directive?> Run(RawSourceFile source) public override async ValueTask<Directive?> Run(RawSourceFile source)

View File

@ -12,14 +12,15 @@ using Wabbajack.Lib.Validation;
namespace Wabbajack.Lib.Downloaders namespace Wabbajack.Lib.Downloaders
{ {
public class GoogleDriveDownloader : IDownloader, IUrlDownloader public class GoogleDriveDownloader : IUrlDownloader
{ {
public async Task<AbstractDownloadState?> GetDownloaderState(dynamic archiveINI, bool quickMode) public async Task<AbstractDownloadState?> GetDownloaderState(dynamic archiveINI, bool quickMode)
{ {
var url = archiveINI?.General?.directURL; var url = archiveINI.General?.directURL;
return GetDownloaderState(url); return GetDownloaderState(url);
} }
private static readonly Regex GDriveRegex = new("((?<=id=)[a-zA-Z0-9_-]*)|(?<=\\/file\\/d\\/)[a-zA-Z0-9_-]*", RegexOptions.Compiled);
public AbstractDownloadState? GetDownloaderState(string? url) public AbstractDownloadState? GetDownloaderState(string? url)
{ {
if (url == null) return null; if (url == null) return null;
@ -27,8 +28,8 @@ namespace Wabbajack.Lib.Downloaders
if (!url.StartsWith("https://drive.google.com")) if (!url.StartsWith("https://drive.google.com"))
return null; return null;
var regex = new Regex("((?<=id=)[a-zA-Z0-9_-]*)|(?<=\\/file\\/d\\/)[a-zA-Z0-9_-]*"); var match = GDriveRegex.Match(url);
var match = regex.Match(url);
return new State(match.ToString()); return new State(match.ToString());
} }

View File

@ -25,19 +25,18 @@ namespace Wabbajack
private readonly ReadOnlyObservableCollection<ModListArchive> _archives; private readonly ReadOnlyObservableCollection<ModListArchive> _archives;
public ReadOnlyObservableCollection<ModListArchive> Archives => _archives; public ReadOnlyObservableCollection<ModListArchive> Archives => _archives;
private static readonly Regex NameMatcher = new(@"(?<=\.)[^\.]+(?=\+State)", RegexOptions.Compiled);
public ModListContentsVM(MainWindowVM mwvm) : base(mwvm) public ModListContentsVM(MainWindowVM mwvm) : base(mwvm)
{ {
_mwvm = mwvm; _mwvm = mwvm;
Status = new ObservableCollectionExtended<DetailedStatusItem>(); Status = new ObservableCollectionExtended<DetailedStatusItem>();
Regex nameMatcher = new Regex(@"(?<=\.)[^\.]+(?=\+State)");
string TransformClassName(Archive a) string TransformClassName(Archive a)
{ {
var cname = a.State.GetType().FullName; var cname = a.State.GetType().FullName;
if (cname == null) return null; if (cname == null) return null;
var match = nameMatcher.Match(cname); var match = NameMatcher.Match(cname);
return match.Success ? match.ToString() : null; return match.Success ? match.ToString() : null;
} }

View File

@ -132,8 +132,11 @@ namespace Wabbajack
canExecute: this.WhenAny(x => x.TargetMod.State.URL) canExecute: this.WhenAny(x => x.TargetMod.State.URL)
.Select(x => .Select(x =>
{ {
var regex = new Regex("^(http|https):\\/\\/"); //var regex = new Regex("^(http|https):\\/\\/");
return x != null && regex.Match(x.ToString()).Success; var scheme = x?.Scheme;
return scheme != null &&
(scheme.Equals("https", StringComparison.OrdinalIgnoreCase) ||
scheme.Equals("http", StringComparison.OrdinalIgnoreCase));
}) })
.ObserveOnGuiThread()); .ObserveOnGuiThread());