mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Catch exception when saving statistics.
This commit is contained in:
@@ -41,8 +41,10 @@ using System.Threading;
|
||||
using System.Xml.Serialization;
|
||||
using Aaru.CommonTypes.Interop;
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.Console;
|
||||
using Aaru.Database;
|
||||
using Aaru.Database.Models;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using Device = Aaru.Devices.Device;
|
||||
@@ -500,14 +502,30 @@ namespace Aaru.Core
|
||||
Name = CommonTypes.Interop.Version.GetVersion(), Synchronized = false, Count = 1
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
catch(SqliteException ex)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Stats", "Exception while trying to save statistics:");
|
||||
AaruConsole.DebugWriteLine("Stats", "{0}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Saves statistics to disk</summary>
|
||||
public static void SaveStats()
|
||||
{
|
||||
try
|
||||
{
|
||||
var ctx = AaruContext.Create(Settings.Settings.LocalDbPath);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
catch(SqliteException ex)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Stats", "Exception while trying to save statistics:");
|
||||
AaruConsole.DebugWriteLine("Stats", "{0}", ex);
|
||||
}
|
||||
|
||||
if(Settings.Settings.Current.Stats != null &&
|
||||
Settings.Settings.Current.Stats.ShareStats)
|
||||
@@ -1163,8 +1181,16 @@ namespace Aaru.Core
|
||||
Name = command, Synchronized = false, Count = 1
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
catch(SqliteException ex)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Stats", "Exception while trying to save statistics:");
|
||||
AaruConsole.DebugWriteLine("Stats", "{0}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Adds a new filesystem to statistics</summary>
|
||||
/// <param name="filesystem">Filesystem name</param>
|
||||
@@ -1184,8 +1210,16 @@ namespace Aaru.Core
|
||||
Name = filesystem, Synchronized = false, Count = 1
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
catch(SqliteException ex)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Stats", "Exception while trying to save statistics:");
|
||||
AaruConsole.DebugWriteLine("Stats", "{0}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Adds a new partition scheme to statistics</summary>
|
||||
/// <param name="partition">Partition scheme name</param>
|
||||
@@ -1205,8 +1239,16 @@ namespace Aaru.Core
|
||||
Name = partition, Synchronized = false, Count = 1
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
catch(SqliteException ex)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Stats", "Exception while trying to save statistics:");
|
||||
AaruConsole.DebugWriteLine("Stats", "{0}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Adds a new filter to statistics</summary>
|
||||
/// <param name="filter">Filter name</param>
|
||||
@@ -1226,8 +1268,16 @@ namespace Aaru.Core
|
||||
Name = filter, Synchronized = false, Count = 1
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
catch(SqliteException ex)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Stats", "Exception while trying to save statistics:");
|
||||
AaruConsole.DebugWriteLine("Stats", "{0}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Ads a new media image to statistics</summary>
|
||||
/// <param name="format">Media image name</param>
|
||||
@@ -1247,8 +1297,16 @@ namespace Aaru.Core
|
||||
Name = format, Synchronized = false, Count = 1
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
catch(SqliteException ex)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Stats", "Exception while trying to save statistics:");
|
||||
AaruConsole.DebugWriteLine("Stats", "{0}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Adds a new device to statistics</summary>
|
||||
/// <param name="dev">Device</param>
|
||||
@@ -1276,8 +1334,16 @@ namespace Aaru.Core
|
||||
Synchronized = false
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
catch(SqliteException ex)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Stats", "Exception while trying to save statistics:");
|
||||
AaruConsole.DebugWriteLine("Stats", "{0}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Adds a new media type to statistics</summary>
|
||||
/// <param name="type">Media type</param>
|
||||
@@ -1295,8 +1361,16 @@ namespace Aaru.Core
|
||||
Real = real, Synchronized = false, Type = type.ToString(), Count = 1
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
catch(SqliteException ex)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Stats", "Exception while trying to save statistics:");
|
||||
AaruConsole.DebugWriteLine("Stats", "{0}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Adds a new remote to statistics</summary>
|
||||
public static void AddRemote(string serverApplication, string serverVersion, string serverOperatingSystem,
|
||||
@@ -1323,7 +1397,15 @@ namespace Aaru.Core
|
||||
Count = 1, Name = serverOperatingSystem, Synchronized = false, Version = serverOperatingSystemVersion
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
catch(SqliteException ex)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Stats", "Exception while trying to save statistics:");
|
||||
AaruConsole.DebugWriteLine("Stats", "{0}", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user