Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assorted bug fixes #242

Merged
merged 4 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gaseous-server/Classes/Collections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public static CollectionContents GetCollectionContent(CollectionItem collectionI
// calculate total rom size for the game
long GameRomSize = 0;
foreach (Roms.GameRomItem gameRom in gameRoms) {
GameRomSize += gameRom.Size;
GameRomSize += (long)gameRom.Size;
}
if (collectionItem.MaximumBytesPerPlatform > 0) {
if ((TotalRomSize + GameRomSize) < collectionItem.MaximumBytesPerPlatform) {
Expand Down Expand Up @@ -749,7 +749,7 @@ public long RomSize {
long Size = 0;
foreach (CollectionGameItem Game in Games) {
foreach (Roms.GameRomItem Rom in Game.Roms) {
Size += Rom.Size;
Size += (long)Rom.Size;
}
}

Expand Down Expand Up @@ -801,7 +801,7 @@ public long RomSize {
get {
long Size = 0;
foreach (Roms.GameRomItem Rom in Roms) {
Size += Rom.Size;
Size += (long)Rom.Size;
}

return Size;
Expand Down
12 changes: 11 additions & 1 deletion gaseous-server/Classes/Common.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Collections.Concurrent;
using System.ComponentModel;
using System.Reflection;
using System.Security.Cryptography;

namespace gaseous_server.Classes
{
public class Common
public static class Common
{
/// <summary>
/// Returns IfNullValue if the ObjectToCheck is null
Expand Down Expand Up @@ -110,6 +112,14 @@ public static string NormalizePath(string path)
return Path.GetFullPath(new Uri(path).LocalPath)
.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
}

public static string GetDescription(this Enum value)
{
return ((DescriptionAttribute)Attribute.GetCustomAttribute(
value.GetType().GetFields(BindingFlags.Public | BindingFlags.Static)
.Single(x => x.GetValue(null).Equals(value)),
typeof(DescriptionAttribute)))?.Description ?? value.ToString();
}
}

/// <summary>
Expand Down
42 changes: 38 additions & 4 deletions gaseous-server/Classes/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,22 +473,56 @@ public void InitLibrary()

public class MetadataAPI
{
private static Communications.MetadataSources _Source
private static HasheousClient.Models.MetadataModel.MetadataSources _MetadataSource
{
get
{
if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("metadatasource")))
{
return (Communications.MetadataSources)Enum.Parse(typeof(Communications.MetadataSources), Environment.GetEnvironmentVariable("metadatasource"));
return (HasheousClient.Models.MetadataModel.MetadataSources)Enum.Parse(typeof(HasheousClient.Models.MetadataModel.MetadataSources), Environment.GetEnvironmentVariable("metadatasource"));
}
else
{
return Communications.MetadataSources.IGDB;
return HasheousClient.Models.MetadataModel.MetadataSources.IGDB;
}
}
}

public Communications.MetadataSources Source = _Source;
private static HasheousClient.Models.MetadataModel.SignatureSources _SignatureSource
{
get
{
if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("signaturesource")))
{
return (HasheousClient.Models.MetadataModel.SignatureSources)Enum.Parse(typeof(HasheousClient.Models.MetadataModel.SignatureSources), Environment.GetEnvironmentVariable("signaturesource"));
}
else
{
return HasheousClient.Models.MetadataModel.SignatureSources.LocalOnly;
}
}
}

private static string _HasheousHost
{
get
{
if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("hasheoushoust")))
{
return Environment.GetEnvironmentVariable("hasheoushoust");
}
else
{
return "https://hasheous.org/";
}
}
}

public HasheousClient.Models.MetadataModel.MetadataSources MetadataSource = _MetadataSource;

public HasheousClient.Models.MetadataModel.SignatureSources SignatureSource = _SignatureSource;

public string HasheousHost = _HasheousHost;
}

public class IGDB
Expand Down
Loading
Loading