Code cleanup

This commit is contained in:
Timothy Baldridge 2020-09-30 21:50:09 -06:00
parent 18c7444541
commit 13068a59e7
25 changed files with 20 additions and 78 deletions

View File

@ -65,10 +65,6 @@ namespace Wabbajack
/// When the switch is on, the source will be subscribed to, and its updates passed through.
/// When the switch is off, the subscription to the source observable will be stopped, and no signal will be published.
/// </summary>
/// <param name="source">Source observable to subscribe to if on</param>
/// <param name="filterSwitch">On/Off signal of whether to subscribe to source observable</param>
/// <param name="valueOnOff">Value to fire when switching off</param>
/// <returns>Observable that publishes data from source, if the switch is on.</returns>
public static IObservable<T> FlowSwitch<T>(this IObservable<T> source, IObservable<bool> filterSwitch, T valueWhenOff)
{
return filterSwitch

View File

@ -742,10 +742,6 @@ namespace Wabbajack.Common
/// <summary>
/// Roundtrips the value through the JSON routines
/// </summary>
/// <typeparam name="TV"></typeparam>
/// <typeparam name="TR"></typeparam>
/// <param name="tv"></param>
/// <returns></returns>
public static T ViaJSON<T>(this T tv)
{
var json = tv.ToJson();
@ -844,7 +840,7 @@ namespace Wabbajack.Common
{
return benchmarkFile.FromJson<long>();
}
catch (Exception ex)
catch (Exception)
{
// ignored
}

View File

@ -192,7 +192,7 @@ namespace Wabbajack.Lib.Downloaders
};
return await Download(newArchive, destination);
}
catch (Exception ex)
catch (Exception)
{
return false;
}

View File

@ -284,7 +284,7 @@ namespace Wabbajack.Lib.Downloaders
return (newArchive, tempFile);
}
public async Task<bool> ValidateUpgrade(Hash srcHash, AbstractDownloadState newArchiveState)
public override async Task<bool> ValidateUpgrade(Hash srcHash, AbstractDownloadState newArchiveState)
{
var state = (State)newArchiveState;
return Game == state.Game && ModID == state.ModID;

View File

@ -6,7 +6,6 @@ using System.IO.MemoryMappedFiles;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using AngleSharp;
using Wabbajack.Common;
using Wabbajack.Common.Exceptions;
using Wabbajack.Common.Serialization.Json;

View File

@ -1,12 +1,9 @@
using Compression.BSA;
using System;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AngleSharp.Common;
using Wabbajack.Common;
using Wabbajack.Lib.CompilationSteps;
using Wabbajack.Lib.Downloaders;

View File

@ -91,7 +91,7 @@ namespace Wabbajack.Lib.ModListRegistry
var client = new Http.Client();
return (await client.GetStringAsync(Consts.UnlistedModlistMetadataURL)).FromJsonString<List<ModlistMetadata>>();
}
catch (Exception ex)
catch (Exception)
{
Utils.LogStatus("Error loading unlisted modlists");
return new List<ModlistMetadata>();

View File

@ -17,16 +17,13 @@
<Version>3.1.0</Version>
</PackageReference>
<PackageReference Include="Fody">
<Version>6.2.5</Version>
<Version>6.2.6</Version>
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Genbox.AlphaFS">
<Version>2.2.2.1</Version>
</PackageReference>
<PackageReference Include="GraphQL.Client">
<Version>3.1.6</Version>
</PackageReference>
<PackageReference Include="HtmlAgilityPack">
<Version>1.11.24</Version>
</PackageReference>
@ -69,9 +66,6 @@
<PackageReference Include="YamlDotNet.NetCore">
<Version>1.0.0</Version>
</PackageReference>
<PackageReference Include="YoutubeExplode">
<Version>5.1.4</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Compression.BSA\Compression.BSA.csproj" />

View File

@ -1,11 +1,9 @@
using System.Net;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Wabbajack.BuildServer.Test;
using Wabbajack.Common;
using Wabbajack.Lib;
using Xunit;
using Xunit.Abstractions;
using Wabbajack.Common;
namespace Wabbajack.Server.Test
{

View File

@ -80,7 +80,7 @@ namespace Wabbajack.BuildServer.Controllers
return NotFound("File is Valid");
}
}
catch (Exception ex)
catch (Exception)
{
//_logger.LogInformation(
// $"Refusing to upgrade ({request.OldArchive.State.PrimaryKeyString}), due to upgrade failure");

View File

@ -3,15 +3,12 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AngleSharp.Io;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Wabbajack.Common;
using Wabbajack.Common.Exceptions;
using Wabbajack.Lib;
using Wabbajack.Lib.NexusApi;
using Wabbajack.Server.DataLayer;
using Wabbajack.Server.Services;

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AngleSharp.Common;
using Dapper;
using Wabbajack.Common;
using Wabbajack.Lib.Downloaders;

View File

@ -17,7 +17,6 @@ namespace Wabbajack.Server.Services
private TimeSpan _delay;
protected ILogger<TP> _logger;
protected QuickSync _quickSync;
private bool _isSetup;
public AbstractService(ILogger<TP> logger, AppSettings settings, QuickSync quickSync, TimeSpan delay)
{
@ -26,7 +25,6 @@ namespace Wabbajack.Server.Services
_logger = logger;
_quickSync = quickSync;
_isSetup = false;
}
public virtual async Task Setup()
@ -42,7 +40,6 @@ namespace Wabbajack.Server.Services
Task.Run(async () =>
{
await Setup();
_isSetup = true;
while (true)

View File

@ -19,8 +19,6 @@ namespace Wabbajack.Server.Services
}
public class DiscordWebHook : AbstractService<DiscordWebHook, int>
{
private AppSettings _settings;
private ILogger<DiscordWebHook> _logger;
private Random _random = new Random();
public DiscordWebHook(ILogger<DiscordWebHook> logger, AppSettings settings, QuickSync quickSync) : base(logger, settings, quickSync, TimeSpan.FromHours(1))

View File

@ -345,7 +345,7 @@ namespace Wabbajack.Server.Services
{
await _sql.AddNexusModInfo(ns.Game, ns.ModID, queryTime, mod);
}
catch (Exception _)
catch (Exception)
{
// Could be a PK constraint failure
}
@ -368,13 +368,13 @@ namespace Wabbajack.Server.Services
{
await _sql.AddNexusModFiles(ns.Game, ns.ModID, queryTime, files);
}
catch (Exception _)
catch (Exception)
{
// Could be a PK constraint failure
}
}
}
catch (Exception ex)
catch (Exception)
{
return ArchiveStatus.InValid;
}

View File

@ -118,7 +118,7 @@ namespace Wabbajack.Server.Services
{
modlist = entry.FromJson<ModList>();
}
catch (JsonReaderException ex)
catch (JsonReaderException)
{
_logger.LogWarning($"Bad Modlist {list.Links.MachineURL}");
await _discord.Send(Channel.Ham,

View File

@ -52,7 +52,7 @@ namespace Wabbajack.Server.Services
var (daily, hourly) = await client.GetRemainingApiCalls();
await _sql.SetNexusAPIKey(key.Key, daily, hourly);
}
catch (Exception ex)
catch (Exception)
{
_logger.Log(LogLevel.Warning, "Update error, purging API key");
await _sql.DeleteNexusAPIKey(key.Key);
@ -82,7 +82,7 @@ namespace Wabbajack.Server.Services
var hourlyRemaining = int.Parse(response.Headers.GetValues("x-rl-hourly-remaining").First());
await _sql.SetNexusAPIKey(ApiKey, dailyRemaining, hourlyRemaining);
}
catch (Exception ex)
catch (Exception)
{
}
}

View File

@ -35,7 +35,6 @@ namespace Wabbajack.Server.Services
_logger.Log(LogLevel.Information, "Starting");
var results = await NexusUpdatesFeeds.GetUpdates();
NexusApiClient client = null;
long updated = 0;
foreach (var result in results)
{

View File

@ -170,11 +170,11 @@ namespace Wabbajack.Server.Services
var lst = p.Split("_", StringSplitOptions.RemoveEmptyEntries).Select(Hash.FromHex).ToArray();
return (lst[0], lst[1]);
}
catch (ArgumentException ex)
catch (ArgumentException)
{
return default;
}
catch (FormatException ex)
catch (FormatException)
{
return default;
}

View File

@ -25,7 +25,7 @@ namespace Wabbajack.VirtualFileSystem.Test
{
_helper.WriteLine(f.ShortDescription);
}
catch (Exception _)
catch (Exception)
{
// ignored
}

View File

@ -31,7 +31,7 @@ namespace Wabbajack.VirtualFileSystem.Test
{
_helper.WriteLine(f.ShortDescription);
}
catch (Exception ex)
catch (Exception)
{
// ignored
}

View File

@ -202,6 +202,7 @@ namespace Wabbajack.VirtualFileSystem
/// Extract the set of files and call the callback for each, handing it a stream factory and the virtual file,
/// top level archives (native archives) will be processed in parallel. Duplicate files will not be
/// </summary>
/// <<param name="queue"></param>
/// <param name="files"></param>
/// <param name="callback"></param>
/// <returns></returns>

View File

@ -49,7 +49,7 @@ namespace Wabbajack.VirtualFileSystem.SevenZipExtractor
{
setter = (ISetProperties)_archive;
}
catch (InvalidCastException _)
catch (InvalidCastException)
{
return;
}

View File

@ -454,31 +454,4 @@ namespace Wabbajack.VirtualFileSystem.SevenZipExtractor
return (uint) this.BaseStream.Read(data, 0, (int) size);
}
}
internal class OutStreamWrapper : StreamWrapper, ISequentialOutStream, IOutStream
{
public OutStreamWrapper(Stream baseStream) : base(baseStream)
{
}
public int SetSize(long newSize)
{
this.BaseStream.SetLength(newSize);
return 0;
}
public int Write(byte[] data, uint size, IntPtr processedSize)
{
throw new NotImplementedException();
/*
this.BaseStream.Write(data, 0, (int) size);
if (processedSize != IntPtr.Zero)
{
Marshal.WriteInt32(processedSize, (int) size);
}
*/
return 0;
}
}
}

View File

@ -23,8 +23,6 @@ namespace Wabbajack.VirtualFileSystem
_vfsCache = RocksDb.Open(options, (string)Consts.LocalAppDataPath.Combine("GlobalVFSCache2.rocksDb"));
}
private AbsolutePath _stagedPath;
private IEnumerable<VirtualFile> _thisAndAllChildren;
public IPath Name { get; internal set; }