aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Network/NetworkClient.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-10-14 18:29:11 -0500
committerJP Dillingham <jp@dillingham.me>2022-10-14 18:29:11 -0500
commita0a984cebed195a814152de95bed480ea9a3d29d (patch)
tree4320d179d24aae7a96fe055ea1fb43f6bca0fdf5 /src/slskd/Network/NetworkClient.cs
parent4d69426a19ffff519368ec2b75e8634fdd23d861 (diff)
downloadslskd-a0a984cebed195a814152de95bed480ea9a3d29d.tar.gz
wip
Diffstat (limited to 'src/slskd/Network/NetworkClient.cs')
-rw-r--r--src/slskd/Network/NetworkClient.cs28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/slskd/Network/NetworkClient.cs b/src/slskd/Network/NetworkClient.cs
index 10e33118..15f114f9 100644
--- a/src/slskd/Network/NetworkClient.cs
+++ b/src/slskd/Network/NetworkClient.cs
@@ -127,7 +127,7 @@ namespace slskd.Network
Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Program.AppName));
Log.Debug("Backing up shares to {Filename}", temp);
- Shares.BackupTo($"Data Source={temp};Pooling=False;"); // quite a leaky abstraction
+ await Shares.DumpAsync(temp);
Log.Debug("Share backup successful");
Log.Debug("Requesting share upload token...");
@@ -136,18 +136,22 @@ namespace slskd.Network
FileStream stream = default;
- try
- {
- stream = new FileStream(temp, FileMode.Open, FileAccess.Read);
- }
- catch (Exception ex)
+ while (true)
{
- // this happens if SQLite hangs on to the connection for whatever reason, seemingly due to pooling
- // Pooling=False should be included in the connection string and this shouldn't be an issue, but
- // since i don't totally understand the behavior, i'll leave this for now.
- Log.Debug(ex, "Failed open stream to backup. Clearing SQLite pools and trying again.");
- SqliteConnection.ClearAllPools();
- stream = new FileStream(temp, FileMode.Open, FileAccess.Read);
+ try
+ {
+ stream = new FileStream(temp, FileMode.Open, FileAccess.Read);
+ break;
+ }
+ catch (Exception ex)
+ {
+ // this happens if SQLite hangs on to the connection for whatever reason, seemingly due to pooling
+ // Pooling=False should be included in the connection string and this shouldn't be an issue, but
+ // since i don't totally understand the behavior, i'll leave this for now.
+ Log.Debug(ex, "Failed open stream to backup. Clearing SQLite pools and trying again.");
+ SqliteConnection.ClearAllPools();
+ await Task.Delay(100);
+ }
}
using var request = new HttpRequestMessage(HttpMethod.Post, $"api/v0/agents/shares/{token}");