Updated Program.cs

While still testing things out, remain in Console mode.
Removed un-used using statements.
Fixed SearchHistorySyner to properly use /searchHistory API end-point.
Added print statement to see when FreeTube closes, and wait for 1.5
seconds before attempting to sync everything up.  May need to increase
this more, needs testing.  (maybe a good 5 seconds would be enough)
This commit is contained in:
Mario Steele 2025-07-24 04:32:51 -05:00
parent fb8284b5e8
commit ea2fb4d818

View file

@ -1,7 +1,5 @@
using Avalonia;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading;
@ -40,7 +38,7 @@ class Program
var historySyncer = new Syncer<History>(dbWatcher, Path.Join(path, "history.db"), "history.db", "/history");
var playlistSyncer = new Syncer<Playlist>(dbWatcher, Path.Join(path, "playlists.db"), "playlists.db", "/playlist");
var profileSyncer = new Syncer<Profile>(dbWatcher, Path.Join(path, "profiles.db"), "profiles.db", "/profile");
var searchHistorySyncer = new Syncer<SearchHistory>(dbWatcher, Path.Join(path, "search-history.db"), "search-history.db", "/search");
var searchHistorySyncer = new Syncer<SearchHistory>(dbWatcher, Path.Join(path, "search-history.db"), "search-history.db", "/searchHistory");
var settingsSyncer = new Syncer<Setting>(dbWatcher, Path.Join(path, "settings.db"), "settings.db", "/settings");
Task.Run(() => CheckCanSync(historySyncer, playlistSyncer, profileSyncer, searchHistorySyncer, settingsSyncer));
@ -56,6 +54,9 @@ class Program
{
Thread.Sleep(100);
if (Process.GetProcessesByName("FreeTube").Length > 0) continue;
Console.WriteLine("FreeTube has closed, we're going to try and update.");
Thread.Sleep(1500);
if (historySyncer is { IsDirty: true })
historySyncer.Sync();
if (playlistSyncer is { IsDirty: true })