From 1887d69479c160c5552f040ea3ba2a4765991602 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Wed, 21 Sep 2022 20:36:05 -0500 Subject: create cache if it cant be loaded --- src/slskd/Application.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/slskd/Application.cs') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index cab2b649..a64fdf36 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -375,6 +375,11 @@ namespace slskd { Log.Warning("Unable to load share cache from disk. A share scan is required."); + // drop all of the existing tables and recreate them + Log.Information("Recreating share cache..."); + await Shares.CreateAsync(discardExisting: true); + Log.Information("Share cache ready."); + State.SetValue(state => state with { Shares = state.Shares with { ScanPending = true } }); if (OptionsAtStartup.Flags.NoShareScan) -- cgit v1.2.3 From c1a4994fd40cf5909008224ce2ce0457cc6342d6 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Wed, 21 Sep 2022 22:54:05 -0500 Subject: remove explicit cache creation --- src/slskd/Application.cs | 9 +++------ src/slskd/Shares/IShareService.cs | 10 ---------- src/slskd/Shares/ISharedFileCache.cs | 6 ------ src/slskd/Shares/ShareService.cs | 14 -------------- 4 files changed, 3 insertions(+), 36 deletions(-) (limited to 'src/slskd/Application.cs') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index a64fdf36..863108c3 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -375,11 +375,6 @@ namespace slskd { Log.Warning("Unable to load share cache from disk. A share scan is required."); - // drop all of the existing tables and recreate them - Log.Information("Recreating share cache..."); - await Shares.CreateAsync(discardExisting: true); - Log.Information("Share cache ready."); - State.SetValue(state => state with { Shares = state.Shares with { ScanPending = true } }); if (OptionsAtStartup.Flags.NoShareScan) @@ -388,6 +383,7 @@ namespace slskd } else { + // todo: should this be forced prior to connection if the cache can't be loaded? _ = Shares.StartScanAsync(); } } @@ -994,7 +990,6 @@ namespace slskd SharesRefreshStarted = DateTime.UtcNow; State.SetValue(s => s with { Shares = current }); - Log.Information("Share scan started"); try { @@ -1005,6 +1000,8 @@ namespace slskd { // noop } + + Log.Information("Share scan started"); } else if (previous.Scanning && !current.Scanning) { diff --git a/src/slskd/Shares/IShareService.cs b/src/slskd/Shares/IShareService.cs index 7ee39313..962d4c1e 100644 --- a/src/slskd/Shares/IShareService.cs +++ b/src/slskd/Shares/IShareService.cs @@ -44,16 +44,6 @@ namespace slskd.Shares /// The entire contents of the share. Task> BrowseAsync(); - /// - /// (Re)Creates the cache. - /// - /// - /// This should generally only be called if has returned false. - /// - /// A value indicating whether an existing cache should be discarded prior to creation. - /// The operation context. - Task CreateAsync(bool discardExisting = false); - /// /// Returns the contents of the specified . /// diff --git a/src/slskd/Shares/ISharedFileCache.cs b/src/slskd/Shares/ISharedFileCache.cs index 61312a37..52c7783c 100644 --- a/src/slskd/Shares/ISharedFileCache.cs +++ b/src/slskd/Shares/ISharedFileCache.cs @@ -39,12 +39,6 @@ namespace slskd.Shares /// The contents of the cache. IEnumerable Browse(); - /// - /// (Re)Creates the cache. - /// - /// A value indicating whether an existing cache should be discarded prior to creation. - void Create(bool discardExisting = false); - /// /// Scans the configured shares and fills the cache. /// diff --git a/src/slskd/Shares/ShareService.cs b/src/slskd/Shares/ShareService.cs index d40be652..96ac4c1c 100644 --- a/src/slskd/Shares/ShareService.cs +++ b/src/slskd/Shares/ShareService.cs @@ -98,20 +98,6 @@ namespace slskd.Shares return Task.FromResult(normalizedResults); } - /// - /// (Re)Creates the cache. - /// - /// - /// This should generally only be called if has returned false. - /// - /// A value indicating whether an existing cache should be discarded prior to creation. - /// The operation context. - public Task CreateAsync(bool discardExisting = false) - { - Cache.Create(discardExisting); - return Task.CompletedTask; - } - /// /// Returns the contents of the specified . /// -- cgit v1.2.3 From aaf7f5285cad30db7f6eb6743456b38635da5ca0 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 22 Sep 2022 08:40:21 -0500 Subject: don't delete browse cache at the start of the scan --- src/slskd/Application.cs | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src/slskd/Application.cs') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 863108c3..aa4c5232 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -991,16 +991,6 @@ namespace slskd State.SetValue(s => s with { Shares = current }); - try - { - System.IO.File.Delete(Path.Combine(Program.DataDirectory, "browse.cache")); - Log.Information("Cleared browse response cache"); - } - catch - { - // noop - } - Log.Information("Share scan started"); } else if (previous.Scanning && !current.Scanning) -- cgit v1.2.3 From a860ffdf0a6f016eee88859728db552c42c63233 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 22 Sep 2022 08:47:38 -0500 Subject: fix misplaced using --- src/slskd/Application.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/slskd/Application.cs') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index aa4c5232..20735ead 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -29,8 +29,8 @@ namespace slskd using System.Net.Sockets; using System.Reflection; using System.Runtime; - using System.Text.RegularExpressions; using System.Runtime.InteropServices; + using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.SignalR; -- cgit v1.2.3