fix: synchronize all writes to ReliableFileStorage

This commit is contained in:
goat 2023-10-04 00:10:04 +02:00
parent 4487ef85f4
commit 38e4fd2673
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B

View file

@ -1,10 +1,8 @@
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using Dalamud.Logging.Internal;
using Dalamud.Utility;
using PInvoke;
using SQLite;
namespace Dalamud.Storage;
@ -28,6 +26,7 @@ public class ReliableFileStorage : IServiceType, IDisposable
{
private static readonly ModuleLog Log = new("VFS");
private readonly object syncRoot = new();
private SQLiteConnection? db;
/// <summary>
@ -118,6 +117,8 @@ public class ReliableFileStorage : IServiceType, IDisposable
{
ArgumentException.ThrowIfNullOrEmpty(path);
lock (this.syncRoot)
{
if (this.db == null)
{
Util.WriteAllBytesSafe(path, bytes);
@ -147,6 +148,7 @@ public class ReliableFileStorage : IServiceType, IDisposable
Util.WriteAllBytesSafe(path, bytes);
});
}
}
/// <summary>
/// Read all text from a file.