Don't allow multiple simultaneous imports
This commit is contained in:
parent
ecaa3b9aab
commit
12abbb79b1
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0-windows</TargetFramework>
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
<Version>7.1.0.1</Version>
|
<Version>7.1.1.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -15,6 +15,18 @@ namespace ApplicationServices
|
|||||||
{
|
{
|
||||||
public static class LibraryCommands
|
public static class LibraryCommands
|
||||||
{
|
{
|
||||||
|
public static event EventHandler<int> ScanBegin;
|
||||||
|
public static event EventHandler ScanEnd;
|
||||||
|
|
||||||
|
public static bool Scanning { get; private set; }
|
||||||
|
private static object _lock { get; } = new();
|
||||||
|
|
||||||
|
static LibraryCommands()
|
||||||
|
{
|
||||||
|
ScanBegin += (_, __) => Scanning = true;
|
||||||
|
ScanEnd += (_, __) => Scanning = false;
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<List<LibraryBook>> FindInactiveBooks(Func<Account, Task<ApiExtended>> apiExtendedfunc, List<LibraryBook> existingLibrary, params Account[] accounts)
|
public static async Task<List<LibraryBook>> FindInactiveBooks(Func<Account, Task<ApiExtended>> apiExtendedfunc, List<LibraryBook> existingLibrary, params Account[] accounts)
|
||||||
{
|
{
|
||||||
logRestart();
|
logRestart();
|
||||||
@ -72,8 +84,6 @@ namespace ApplicationServices
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static event EventHandler<int> ScanBegin;
|
|
||||||
public static event EventHandler ScanEnd;
|
|
||||||
#region FULL LIBRARY scan and import
|
#region FULL LIBRARY scan and import
|
||||||
public static async Task<(int totalCount, int newCount)> ImportAccountAsync(Func<Account, Task<ApiExtended>> apiExtendedfunc, params Account[] accounts)
|
public static async Task<(int totalCount, int newCount)> ImportAccountAsync(Func<Account, Task<ApiExtended>> apiExtendedfunc, params Account[] accounts)
|
||||||
{
|
{
|
||||||
@ -84,7 +94,12 @@ namespace ApplicationServices
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
if (Scanning)
|
||||||
|
return (0, 0);
|
||||||
ScanBegin?.Invoke(null, accounts.Length);
|
ScanBegin?.Invoke(null, accounts.Length);
|
||||||
|
}
|
||||||
|
|
||||||
logTime($"pre {nameof(scanAccountsAsync)} all");
|
logTime($"pre {nameof(scanAccountsAsync)} all");
|
||||||
var importItems = await scanAccountsAsync(apiExtendedfunc, accounts, LibraryOptions.ResponseGroupOptions.ALL_OPTIONS);
|
var importItems = await scanAccountsAsync(apiExtendedfunc, accounts, LibraryOptions.ResponseGroupOptions.ALL_OPTIONS);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user