mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-07-05 12:38:51 +02:00
Compare commits
1 Commits
5970fc4e9a
...
62bd9c0420
Author | SHA1 | Date | |
---|---|---|---|
![]() |
62bd9c0420 |
@ -69,7 +69,7 @@ sealed class Arguments {
|
|||||||
Log.Warn("Invalid concurrent downloads count: " + value);
|
Log.Warn("Invalid concurrent downloads count: " + value);
|
||||||
}
|
}
|
||||||
else if (concurrentDownloads > 10) {
|
else if (concurrentDownloads > 10) {
|
||||||
Log.Warn("Limiting concurrent downloads to 10.");
|
Log.Warn("Limiting concurrent downloads to 10");
|
||||||
ConcurrentDownloads = 10;
|
ConcurrentDownloads = 10;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -52,7 +52,7 @@ static class DatabaseGui {
|
|||||||
} catch (DatabaseTooNewException ex) {
|
} catch (DatabaseTooNewException ex) {
|
||||||
await Dialog.ShowOk(window, "Database Error", "Database '" + Path.GetFileName(path) + "' was opened in a newer version of DHT (database version " + ex.DatabaseVersion + ", app version " + ex.CurrentVersion + ").");
|
await Dialog.ShowOk(window, "Database Error", "Database '" + Path.GetFileName(path) + "' was opened in a newer version of DHT (database version " + ex.DatabaseVersion + ", app version " + ex.CurrentVersion + ").");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.Error("Could not open database file: " + path, ex);
|
Log.Error(ex);
|
||||||
await Dialog.ShowOk(window, "Database Error", "Database '" + Path.GetFileName(path) + "' could not be opened:" + ex.Message);
|
await Dialog.ShowOk(window, "Database Error", "Database '" + Path.GetFileName(path) + "' could not be opened:" + ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,8 @@ static class DiscordAppSettings {
|
|||||||
JsonObject settingsJson = await ReadSettingsJson();
|
JsonObject settingsJson = await ReadSettingsJson();
|
||||||
return AreDevToolsEnabled(settingsJson);
|
return AreDevToolsEnabled(settingsJson);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error("Could not read settings file.", e);
|
Log.Error("Cannot read settings file.");
|
||||||
|
Log.Error(e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,7 +62,7 @@ static class DiscordAppSettings {
|
|||||||
} catch (JsonException) {
|
} catch (JsonException) {
|
||||||
return SettingsJsonResult.InvalidJson;
|
return SettingsJsonResult.InvalidJson;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error("Could not read settings file.", e);
|
Log.Error(e);
|
||||||
return SettingsJsonResult.ReadError;
|
return SettingsJsonResult.ReadError;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,14 +84,16 @@ static class DiscordAppSettings {
|
|||||||
|
|
||||||
await WriteSettingsJson(json);
|
await WriteSettingsJson(json);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error("Could not write settings file.", e);
|
Log.Error("An error occurred when writing settings file.");
|
||||||
|
Log.Error(e);
|
||||||
|
|
||||||
if (File.Exists(JsonBackupFilePath)) {
|
if (File.Exists(JsonBackupFilePath)) {
|
||||||
try {
|
try {
|
||||||
File.Move(JsonBackupFilePath, JsonFilePath, overwrite: true);
|
File.Move(JsonBackupFilePath, JsonFilePath, overwrite: true);
|
||||||
Log.Info("Restored settings file from backup.");
|
Log.Info("Restored settings file from backup.");
|
||||||
} catch (Exception e2) {
|
} catch (Exception e2) {
|
||||||
Log.Error("Could not restore settings file from backup.", e2);
|
Log.Error("Cannot restore settings file from backup.");
|
||||||
|
Log.Error(e2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +103,8 @@ static class DiscordAppSettings {
|
|||||||
try {
|
try {
|
||||||
File.Delete(JsonBackupFilePath);
|
File.Delete(JsonBackupFilePath);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error("Could not delete backup file.", e);
|
Log.Error("Cannot delete backup file.");
|
||||||
|
Log.Error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SettingsJsonResult.Success;
|
return SettingsJsonResult.Success;
|
||||||
|
@ -109,7 +109,8 @@ sealed partial class DownloadItemFilterPanelModel : IAsyncDisposable {
|
|||||||
await setter.Set(SettingsKey.DownloadsMaximumSizeUnit, settings.MaximumSizeUnit.Name);
|
await setter.Set(SettingsKey.DownloadsMaximumSizeUnit, settings.MaximumSizeUnit.Name);
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error("Could not save download filter settings.", e);
|
Log.Error("Could not save download filter settings");
|
||||||
|
Log.Error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ sealed partial class ServerConfigurationPanelModel : IDisposable {
|
|||||||
try {
|
try {
|
||||||
await server.Start(ServerConfiguration.Port, ServerConfiguration.Token);
|
await server.Start(ServerConfiguration.Port, ServerConfiguration.Token);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error("Could not start internal server.", e);
|
Log.Error(e);
|
||||||
await Dialog.ShowOk(window, "Internal Server Error", e.Message);
|
await Dialog.ShowOk(window, "Internal Server Error", e.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ sealed partial class ServerConfigurationPanelModel : IDisposable {
|
|||||||
try {
|
try {
|
||||||
await server.Stop();
|
await server.Stop();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error("Could not stop internal server.", e);
|
Log.Error(e);
|
||||||
await Dialog.ShowOk(window, "Internal Server Error", e.Message);
|
await Dialog.ShowOk(window, "Internal Server Error", e.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,21 +89,14 @@ sealed partial class MainWindowModel : IAsyncDisposable {
|
|||||||
try {
|
try {
|
||||||
await state.Server.Start(ServerConfiguration.Port, ServerConfiguration.Token);
|
await state.Server.Start(ServerConfiguration.Port, ServerConfiguration.Token);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.Error("Could not start internal server.", ex);
|
Log.Error(ex);
|
||||||
await Dialog.ShowOk(window, "Internal Server Error", ex.Message);
|
await Dialog.ShowOk(window, "Internal Server Error", ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
mainContentScreenModel = new MainContentScreenModel(window, state);
|
||||||
mainContentScreenModel = new MainContentScreenModel(window, state);
|
mainContentScreenModel.DatabaseClosed += MainContentScreenModelOnDatabaseClosed;
|
||||||
mainContentScreenModel.DatabaseClosed += MainContentScreenModelOnDatabaseClosed;
|
|
||||||
await mainContentScreenModel.Initialize();
|
await mainContentScreenModel.Initialize();
|
||||||
} catch (Exception ex) {
|
|
||||||
Log.Error("Could not initialize content screen.", ex);
|
|
||||||
await Dialog.ShowOk(window, "Initialization Error", ex.Message);
|
|
||||||
await DisposeContent();
|
|
||||||
await DisposeState();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Title = Path.GetFileName(state.Db.Path) + " - " + DefaultTitle;
|
Title = Path.GetFileName(state.Db.Path) + " - " + DefaultTitle;
|
||||||
CurrentScreen = new MainContentScreen { DataContext = mainContentScreenModel };
|
CurrentScreen = new MainContentScreen { DataContext = mainContentScreenModel };
|
||||||
|
@ -84,7 +84,7 @@ sealed class DatabasePageModel {
|
|||||||
try {
|
try {
|
||||||
result = await ProgressDialog.Show(window, Title, async (dialog, callback) => await MergeWithDatabaseFromPaths(Db, paths, dialog, callback));
|
result = await ProgressDialog.Show(window, Title, async (dialog, callback) => await MergeWithDatabaseFromPaths(Db, paths, dialog, callback));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error("Could not merge databases.", e);
|
Log.Error(e);
|
||||||
await Dialog.ShowOk(window, Title, "Could not merge databases: " + e.Message);
|
await Dialog.ShowOk(window, Title, "Could not merge databases: " + e.Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ sealed class DatabasePageModel {
|
|||||||
try {
|
try {
|
||||||
result = await ProgressDialog.Show(window, Title, async (dialog, callback) => await ImportLegacyArchiveFromPaths(Db, paths, dialog, callback));
|
result = await ProgressDialog.Show(window, Title, async (dialog, callback) => await ImportLegacyArchiveFromPaths(Db, paths, dialog, callback));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error("Could not import legacy archives.", e);
|
Log.Error(e);
|
||||||
await Dialog.ShowOk(window, Title, "Could not import legacy archives: " + e.Message);
|
await Dialog.ShowOk(window, Title, "Could not import legacy archives: " + e.Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -236,7 +236,7 @@ sealed class DatabasePageModel {
|
|||||||
++successful;
|
++successful;
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.Error("Could not import file: " + path, ex);
|
Log.Error(ex);
|
||||||
await Dialog.ShowOk(dialog, dialogTitle, "File '" + Path.GetFileName(path) + "' could not be imported: " + ex.Message);
|
await Dialog.ShowOk(dialog, dialogTitle, "File '" + Path.GetFileName(path) + "' could not be imported: " + ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -302,7 +302,7 @@ sealed class DatabasePageModel {
|
|||||||
try {
|
try {
|
||||||
await ProgressDialog.ShowIndeterminate(window, Title, "Vacuuming database...", _ => Db.Vacuum());
|
await ProgressDialog.ShowIndeterminate(window, Title, "Vacuuming database...", _ => Db.Vacuum());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error("Could not vacuum database.", e);
|
Log.Error(e);
|
||||||
await Dialog.ShowOk(window, Title, "Could not vacuum database: " + e.Message);
|
await Dialog.ShowOk(window, Title, "Could not vacuum database: " + e.Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,5 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
</Expander>
|
</Expander>
|
||||||
<Expander Header="About" IsExpanded="True">
|
|
||||||
<TextBlock Text="{Binding SqliteVersion, StringFormat=Sqlite Version: {0}}" />
|
|
||||||
</Expander>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
@ -9,18 +9,14 @@ using DHT.Desktop.Dialogs.Progress;
|
|||||||
using DHT.Server;
|
using DHT.Server;
|
||||||
using DHT.Server.Data;
|
using DHT.Server.Data;
|
||||||
using DHT.Server.Service;
|
using DHT.Server.Service;
|
||||||
using PropertyChanged.SourceGenerator;
|
|
||||||
|
|
||||||
namespace DHT.Desktop.Main.Pages;
|
namespace DHT.Desktop.Main.Pages;
|
||||||
|
|
||||||
sealed partial class DebugPageModel {
|
sealed class DebugPageModel {
|
||||||
public string GenerateChannels { get; set; } = "0";
|
public string GenerateChannels { get; set; } = "0";
|
||||||
public string GenerateUsers { get; set; } = "0";
|
public string GenerateUsers { get; set; } = "0";
|
||||||
public string GenerateMessages { get; set; } = "0";
|
public string GenerateMessages { get; set; } = "0";
|
||||||
|
|
||||||
[Notify(Setter.Private)]
|
|
||||||
private string? sqliteVersion = string.Empty;
|
|
||||||
|
|
||||||
private readonly Window window;
|
private readonly Window window;
|
||||||
private readonly State state;
|
private readonly State state;
|
||||||
|
|
||||||
@ -32,10 +28,6 @@ sealed partial class DebugPageModel {
|
|||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Initialize() {
|
|
||||||
SqliteVersion = await state.Db.GetVersion() ?? "<unknown>";
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void OnClickAddRandomDataToDatabase() {
|
public async void OnClickAddRandomDataToDatabase() {
|
||||||
if (!int.TryParse(GenerateChannels, out int channels) || channels < 1) {
|
if (!int.TryParse(GenerateChannels, out int channels) || channels < 1) {
|
||||||
await Dialog.ShowOk(window, "Generate Random Data", "Amount of channels must be at least 1!");
|
await Dialog.ShowOk(window, "Generate Random Data", "Amount of channels must be at least 1!");
|
||||||
@ -177,8 +169,6 @@ sealed class DebugPageModel {
|
|||||||
public string GenerateUsers { get; set; } = "0";
|
public string GenerateUsers { get; set; } = "0";
|
||||||
public string GenerateMessages { get; set; } = "0";
|
public string GenerateMessages { get; set; } = "0";
|
||||||
|
|
||||||
public string SqliteVersion => string.Empty;
|
|
||||||
|
|
||||||
public void OnClickAddRandomDataToDatabase() {}
|
public void OnClickAddRandomDataToDatabase() {}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -92,12 +92,7 @@ sealed partial class DownloadsPageModel : IAsyncDisposable {
|
|||||||
await FilterModel.Initialize();
|
await FilterModel.Initialize();
|
||||||
|
|
||||||
if (await state.Db.Settings.Get(SettingsKey.DownloadsAutoStart, defaultValue: false)) {
|
if (await state.Db.Settings.Get(SettingsKey.DownloadsAutoStart, defaultValue: false)) {
|
||||||
try {
|
await StartDownload();
|
||||||
await StartDownload();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.Error("Could not automatically start downloads.", e);
|
|
||||||
await Dialog.ShowOk(window, "Database Error", "Could not automatically start downloads: " + e.Message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,43 +111,23 @@ sealed partial class DownloadsPageModel : IAsyncDisposable {
|
|||||||
|
|
||||||
public async Task OnClickToggleDownload() {
|
public async Task OnClickToggleDownload() {
|
||||||
IsToggleDownloadButtonEnabled = false;
|
IsToggleDownloadButtonEnabled = false;
|
||||||
try {
|
|
||||||
if (IsDownloading) {
|
if (IsDownloading) {
|
||||||
await StopDownload();
|
await StopDownload();
|
||||||
}
|
|
||||||
else {
|
|
||||||
try {
|
|
||||||
await StartDownload();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.Error("Could not start downloads.", e);
|
|
||||||
await Dialog.ShowOk(window, "Database Error", "Could not start downloads: " + e.Message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await state.Db.Settings.Set(SettingsKey.DownloadsAutoStart, IsDownloading);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.Error("Could not update auto-start setting in database.", e);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
IsToggleDownloadButtonEnabled = true;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
await StartDownload();
|
||||||
|
}
|
||||||
|
|
||||||
|
await state.Db.Settings.Set(SettingsKey.DownloadsAutoStart, IsDownloading);
|
||||||
|
IsToggleDownloadButtonEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task StartDownload() {
|
private async Task StartDownload() {
|
||||||
await state.Db.Downloads.MoveDownloadingItemsBackToQueue();
|
await state.Db.Downloads.MoveDownloadingItemsBackToQueue();
|
||||||
|
|
||||||
try {
|
IObservable<DownloadItem> finishedItems = await state.Downloader.Start(currentDownloadFilter = FilterModel.CreateFilter());
|
||||||
currentDownloadFilter = FilterModel.CreateFilter();
|
finishedItemsSubscription = finishedItems.ObserveOn(AvaloniaScheduler.Instance).Subscribe(OnItemFinished);
|
||||||
IObservable<DownloadItem> finishedItems = await state.Downloader.Start(currentDownloadFilter);
|
|
||||||
finishedItemsSubscription = finishedItems.ObserveOn(AvaloniaScheduler.Instance).Subscribe(OnItemFinished);
|
|
||||||
} catch (Exception) {
|
|
||||||
finishedItemsSubscription?.Dispose();
|
|
||||||
finishedItemsSubscription = null;
|
|
||||||
currentDownloadFilter = null;
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
OnDownloadStateChanged();
|
OnDownloadStateChanged();
|
||||||
}
|
}
|
||||||
@ -163,8 +138,8 @@ sealed partial class DownloadsPageModel : IAsyncDisposable {
|
|||||||
|
|
||||||
finishedItemsSubscription?.Dispose();
|
finishedItemsSubscription?.Dispose();
|
||||||
finishedItemsSubscription = null;
|
finishedItemsSubscription = null;
|
||||||
currentDownloadFilter = null;
|
|
||||||
|
|
||||||
|
currentDownloadFilter = null;
|
||||||
OnDownloadStateChanged();
|
OnDownloadStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,12 +155,12 @@ sealed partial class DownloadsPageModel : IAsyncDisposable {
|
|||||||
|
|
||||||
public async Task OnClickRetryFailed() {
|
public async Task OnClickRetryFailed() {
|
||||||
IsRetryingFailedDownloads = true;
|
IsRetryingFailedDownloads = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await state.Db.Downloads.RetryFailed();
|
await state.Db.Downloads.RetryFailed();
|
||||||
RecomputeDownloadStatistics();
|
RecomputeDownloadStatistics();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error("Could not retry failed downloads.", e);
|
Log.Error(e);
|
||||||
await Dialog.ShowOk(window, "Retry Failed", "Could not retry failed downloads: " + e.Message);
|
|
||||||
} finally {
|
} finally {
|
||||||
IsRetryingFailedDownloads = false;
|
IsRetryingFailedDownloads = false;
|
||||||
}
|
}
|
||||||
@ -237,7 +212,7 @@ sealed partial class DownloadsPageModel : IAsyncDisposable {
|
|||||||
await state.Db.Vacuum();
|
await state.Db.Vacuum();
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error("Could not delete orphaned downloads.", e);
|
Log.Error(e);
|
||||||
await Dialog.ShowOk(window, Title, "Could not delete orphaned downloads: " + e.Message);
|
await Dialog.ShowOk(window, Title, "Could not delete orphaned downloads: " + e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -264,7 +239,7 @@ sealed partial class DownloadsPageModel : IAsyncDisposable {
|
|||||||
return await exporter.Export(new ExportProgressReporter(callback));
|
return await exporter.Export(new ExportProgressReporter(callback));
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error("Could not export downloaded files.", e);
|
Log.Error(e);
|
||||||
await Dialog.ShowOk(window, Title, "Could not export downloaded files: " + e.Message);
|
await Dialog.ShowOk(window, Title, "Could not export downloaded files: " + e.Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ sealed partial class TrackingPageModel {
|
|||||||
await clipboard.SetTextAsync(script);
|
await clipboard.SetTextAsync(script);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error("Could not copy to clipboard.", e);
|
Log.Error(e);
|
||||||
await Dialog.ShowOk(window, errorDialogTitle, "An error occurred while copying to clipboard.");
|
await Dialog.ShowOk(window, errorDialogTitle, "An error occurred while copying to clipboard.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ sealed partial class ViewerPageModel : IDisposable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error("Could not apply filters.", e);
|
Log.Error(e);
|
||||||
await Dialog.ShowOk(window, "Apply Filters", "Could not apply filters: " + e.Message);
|
await Dialog.ShowOk(window, "Apply Filters", "Could not apply filters: " + e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,10 +70,6 @@ sealed class MainContentScreenModel : IAsyncDisposable {
|
|||||||
|
|
||||||
public async Task Initialize() {
|
public async Task Initialize() {
|
||||||
await DownloadsPageModel.Initialize();
|
await DownloadsPageModel.Initialize();
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
await DebugPageModel.Initialize();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async ValueTask DisposeAsync() {
|
public async ValueTask DisposeAsync() {
|
||||||
|
@ -131,7 +131,7 @@ sealed partial class WelcomeScreenModel {
|
|||||||
await Dialog.ShowOk(window, "Check Updates", "Request timed out.");
|
await Dialog.ShowOk(window, "Check Updates", "Request timed out.");
|
||||||
return;
|
return;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error("Could not check for updates.", e);
|
Log.Error(e);
|
||||||
await Dialog.ShowOk(window, "Check Updates", "Error checking for updates: " + e.Message);
|
await Dialog.ShowOk(window, "Check Updates", "Error checking for updates: " + e.Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ class DISCORD {
|
|||||||
/**
|
/**
|
||||||
* @type {function(String): MessageData}
|
* @type {function(String): MessageData}
|
||||||
*/
|
*/
|
||||||
static #getMessages = WEBPACK.findFunction("getMessages", [ "isLoadingMessages" ]);
|
static #getMessages = WEBPACK.findFunction("getMessages");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {function(String): void}
|
* @type {function(String): void}
|
||||||
|
@ -88,7 +88,7 @@ class WEBPACK {
|
|||||||
return modules[0];
|
return modules[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
console.error("[DHT] Cannot find module " + name + ", results found:", modules.length, modules);
|
console.error("[DHT] Cannot find module " + name + ", results found:", modules.length);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,10 +19,6 @@ sealed class DummyDatabaseFile : IDatabaseFile {
|
|||||||
|
|
||||||
private DummyDatabaseFile() {}
|
private DummyDatabaseFile() {}
|
||||||
|
|
||||||
public Task<string?> GetVersion() {
|
|
||||||
return Task.FromResult<string?>(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task Vacuum() {
|
public Task Vacuum() {
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,5 @@ public interface IDatabaseFile : IAsyncDisposable {
|
|||||||
IMessageRepository Messages { get; }
|
IMessageRepository Messages { get; }
|
||||||
IDownloadRepository Downloads { get; }
|
IDownloadRepository Downloads { get; }
|
||||||
|
|
||||||
Task<string?> GetVersion();
|
|
||||||
Task Vacuum();
|
Task Vacuum();
|
||||||
}
|
}
|
||||||
|
@ -80,11 +80,6 @@ public sealed class SqliteDatabaseFile : IDatabaseFile {
|
|||||||
await pool.DisposeAsync();
|
await pool.DisposeAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string?> GetVersion() {
|
|
||||||
await using var conn = await pool.Take();
|
|
||||||
return await conn.ExecuteReaderAsync("SELECT sqlite_version()", static reader => reader?.GetString(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task Vacuum() {
|
public async Task Vacuum() {
|
||||||
await using var conn = await pool.Take();
|
await using var conn = await pool.Take();
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ public sealed partial class DownloadExporter(IDatabaseFile db, string folderPath
|
|||||||
} catch (FileAlreadyExistsException) {
|
} catch (FileAlreadyExistsException) {
|
||||||
success = false;
|
success = false;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error("Could not export downloaded file: " + download.NormalizedUrl, e);
|
Log.Error(e);
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Reactive.Subjects;
|
using System.Reactive.Subjects;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@ -95,10 +94,12 @@ sealed class DownloaderTask : IAsyncDisposable {
|
|||||||
} catch (TaskCanceledException e) when (e.InnerException is TimeoutException) {
|
} catch (TaskCanceledException e) when (e.InnerException is TimeoutException) {
|
||||||
await db.Downloads.AddDownload(item.ToFailure(), stream: null);
|
await db.Downloads.AddDownload(item.ToFailure(), stream: null);
|
||||||
log.Error("Download timed out: " + item.DownloadUrl);
|
log.Error("Download timed out: " + item.DownloadUrl);
|
||||||
|
} catch (HttpRequestException e) {
|
||||||
|
await db.Downloads.AddDownload(item.ToFailure(e.StatusCode), stream: null);
|
||||||
|
log.Error(e);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
HttpStatusCode? statusCode = e is HttpRequestException hre ? hre.StatusCode : null;
|
await db.Downloads.AddDownload(item.ToFailure(), stream: null);
|
||||||
await db.Downloads.AddDownload(item.ToFailure(statusCode), stream: null);
|
log.Error(e);
|
||||||
log.Error("Could not download file: " + item.DownloadUrl, e);
|
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
finishedItemPublisher.OnNext(item);
|
finishedItemPublisher.OnNext(item);
|
||||||
|
@ -33,7 +33,7 @@ abstract class BaseEndpoint {
|
|||||||
await response.WriteAsync(e.Message);
|
await response.WriteAsync(e.Message);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Error("Could not handle request.", e);
|
Log.Error(e);
|
||||||
response.StatusCode = (int) HttpStatusCode.InternalServerError;
|
response.StatusCode = (int) HttpStatusCode.InternalServerError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.6" />
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.7" />
|
||||||
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
|
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -30,11 +30,11 @@ sealed class ServerLoggingMiddleware(RequestDelegate next) {
|
|||||||
long elapsedMs = stopwatch.ElapsedMilliseconds;
|
long elapsedMs = stopwatch.ElapsedMilliseconds;
|
||||||
|
|
||||||
if (context.RequestAborted.IsCancellationRequested) {
|
if (context.RequestAborted.IsCancellationRequested) {
|
||||||
Log.Debug("Request to " + request.GetEncodedPathAndQuery() + " (" + requestLength + " B) was cancelled after " + elapsedMs + " ms.");
|
Log.Debug("Request to " + request.GetEncodedPathAndQuery() + " (" + requestLength + " B) was cancelled after " + elapsedMs + " ms");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int responseStatus = context.Response.StatusCode;
|
int responseStatus = context.Response.StatusCode;
|
||||||
Log.Debug("Request to " + request.GetEncodedPathAndQuery() + " (" + requestLength + " B) returned " + responseStatus + ", took " + elapsedMs + " ms.");
|
Log.Debug("Request to " + request.GetEncodedPathAndQuery() + " (" + requestLength + " B) returned " + responseStatus + ", took " + elapsedMs + " ms");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ public sealed class ServerManager {
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.Info("Server started.");
|
Log.Info("Server started");
|
||||||
|
|
||||||
server = newServer;
|
server = newServer;
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ public sealed class ServerManager {
|
|||||||
|
|
||||||
Log.Info("Stopping server...");
|
Log.Info("Stopping server...");
|
||||||
await server.StopAsync();
|
await server.StopAsync();
|
||||||
Log.Info("Server stopped.");
|
Log.Info("Server stopped");
|
||||||
|
|
||||||
server.Dispose();
|
server.Dispose();
|
||||||
server = null;
|
server = null;
|
||||||
|
@ -88,11 +88,6 @@ public sealed class Log {
|
|||||||
LogLevel(ConsoleColor.Red, "ERROR", e.ToString());
|
LogLevel(ConsoleColor.Red, "ERROR", e.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Error(string message, Exception e) {
|
|
||||||
Error(message);
|
|
||||||
Error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Perf Start(string? context = null, [CallerMemberName] string callerMemberName = "") {
|
public Perf Start(string? context = null, [CallerMemberName] string callerMemberName = "") {
|
||||||
return Perf.Start(this, context, callerMemberName);
|
return Perf.Start(this, context, callerMemberName);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user