mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-23 00:07:49 +01:00
feat: wrap writes in a transaction
This commit is contained in:
parent
f027b684ed
commit
c1fd08cc93
1 changed files with 19 additions and 16 deletions
|
|
@ -95,6 +95,8 @@ public class ReliableFileStorage : IServiceType, IDisposable
|
||||||
{
|
{
|
||||||
ArgumentException.ThrowIfNullOrEmpty(path);
|
ArgumentException.ThrowIfNullOrEmpty(path);
|
||||||
|
|
||||||
|
this.db.RunInTransaction(() =>
|
||||||
|
{
|
||||||
var normalizedPath = NormalizePath(path);
|
var normalizedPath = NormalizePath(path);
|
||||||
var file = this.db.Table<DbFile>().FirstOrDefault(f => f.Path == normalizedPath && f.ContainerId == containerId);
|
var file = this.db.Table<DbFile>().FirstOrDefault(f => f.Path == normalizedPath && f.ContainerId == containerId);
|
||||||
if (file == null)
|
if (file == null)
|
||||||
|
|
@ -114,6 +116,7 @@ public class ReliableFileStorage : IServiceType, IDisposable
|
||||||
}
|
}
|
||||||
|
|
||||||
Util.WriteAllBytesSafe(path, bytes);
|
Util.WriteAllBytesSafe(path, bytes);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue