mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-05-09 07:46:13 -04:00
Fix race condition on vault import with multiple folders (#1786)
This commit is contained in:
committed by
Leendert de Borst
parent
c631326706
commit
db9d8e3ead
@@ -804,8 +804,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Create new folder with parent relationship
|
||||
var newFolderId = await FolderService.CreateAsync(folderName, parentFolderId);
|
||||
// Create new folder with parent relationship. Skip per-folder background sync —
|
||||
// the final DbService.SaveDatabaseAsync() at the end of the import covers all mutations.
|
||||
var newFolderId = await FolderService.CreateAsync(folderName, parentFolderId, syncToServer: false);
|
||||
folderPathToId[folderPath] = newFolderId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,8 +91,10 @@ public sealed class FolderService(DbService dbService)
|
||||
/// </summary>
|
||||
/// <param name="name">The folder name.</param>
|
||||
/// <param name="parentFolderId">Optional parent folder ID.</param>
|
||||
/// <param name="syncToServer">Whether to trigger a background sync to the server. Set to false when
|
||||
/// the caller will batch multiple mutations and perform a single sync afterwards (e.g. bulk import).</param>
|
||||
/// <returns>The created folder ID.</returns>
|
||||
public async Task<Guid> CreateAsync(string name, Guid? parentFolderId = null)
|
||||
public async Task<Guid> CreateAsync(string name, Guid? parentFolderId = null, bool syncToServer = true)
|
||||
{
|
||||
var context = await dbService.GetDbContextAsync();
|
||||
|
||||
@@ -109,7 +111,11 @@ public sealed class FolderService(DbService dbService)
|
||||
|
||||
context.Folders.Add(folder);
|
||||
await context.SaveChangesAsync();
|
||||
dbService.SaveDatabaseInBackground();
|
||||
|
||||
if (syncToServer)
|
||||
{
|
||||
dbService.SaveDatabaseInBackground();
|
||||
}
|
||||
|
||||
return folder.Id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user