mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Handling race conditions on create if not exists of every repositories
This commit is contained in:
parent
57ade5470f
commit
7694bd97ae
@ -106,7 +106,17 @@ namespace Kyoo.Controllers
|
||||
Episode old = await Get(obj.Slug);
|
||||
if (old != null)
|
||||
return old.ID;
|
||||
return await Create(obj);
|
||||
try
|
||||
{
|
||||
return await Create(obj);
|
||||
}
|
||||
catch (DuplicatedItemException)
|
||||
{
|
||||
old = await Get(obj.Slug);
|
||||
if (old == null)
|
||||
throw new SystemException("Unknown database state.");
|
||||
return old.ID;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Edit(Episode edited, bool resetOld)
|
||||
|
@ -80,7 +80,17 @@ namespace Kyoo.Controllers
|
||||
Genre old = await Get(obj.Slug);
|
||||
if (old != null)
|
||||
return old.ID;
|
||||
return await Create(obj);
|
||||
try
|
||||
{
|
||||
return await Create(obj);
|
||||
}
|
||||
catch (DuplicatedItemException)
|
||||
{
|
||||
old = await Get(obj.Slug);
|
||||
if (old == null)
|
||||
throw new SystemException("Unknown database state.");
|
||||
return old.ID;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Edit(Genre edited, bool resetOld)
|
||||
|
@ -84,10 +84,20 @@ namespace Kyoo.Controllers
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
|
||||
Library old = await Get(obj.Name);
|
||||
Library old = await Get(obj.Slug);
|
||||
if (old != null)
|
||||
return old.ID;
|
||||
return await Create(obj);
|
||||
try
|
||||
{
|
||||
return await Create(obj);
|
||||
}
|
||||
catch (DuplicatedItemException)
|
||||
{
|
||||
old = await Get(obj.Slug);
|
||||
if (old == null)
|
||||
throw new SystemException("Unknown database state.");
|
||||
return old.ID;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Edit(Library edited, bool resetOld)
|
||||
|
@ -86,7 +86,17 @@ namespace Kyoo.Controllers
|
||||
People old = await Get(obj.Slug);
|
||||
if (old != null)
|
||||
return old.ID;
|
||||
return await Create(obj);
|
||||
try
|
||||
{
|
||||
return await Create(obj);
|
||||
}
|
||||
catch (DuplicatedItemException)
|
||||
{
|
||||
old = await Get(obj.Slug);
|
||||
if (old == null)
|
||||
throw new SystemException("Unknown database state.");
|
||||
return old.ID;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Edit(People edited, bool resetOld)
|
||||
|
@ -80,7 +80,17 @@ namespace Kyoo.Controllers
|
||||
ProviderID old = await Get(obj.Name);
|
||||
if (old != null)
|
||||
return old.ID;
|
||||
return await Create(obj);
|
||||
try
|
||||
{
|
||||
return await Create(obj);
|
||||
}
|
||||
catch (DuplicatedItemException)
|
||||
{
|
||||
old = await Get(obj.Name);
|
||||
if (old == null)
|
||||
throw new SystemException("Unknown database state.");
|
||||
return old.ID;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Edit(ProviderID edited, bool resetOld)
|
||||
|
@ -99,7 +99,17 @@ namespace Kyoo.Controllers
|
||||
Season old = await Get(obj.Slug);
|
||||
if (old != null)
|
||||
return old.ID;
|
||||
return await Create(obj);
|
||||
try
|
||||
{
|
||||
return await Create(obj);
|
||||
}
|
||||
catch (DuplicatedItemException)
|
||||
{
|
||||
old = await Get(obj.Slug);
|
||||
if (old == null)
|
||||
throw new SystemException("Unknown database state.");
|
||||
return old.ID;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Edit(Season edited, bool resetOld)
|
||||
|
@ -103,7 +103,17 @@ namespace Kyoo.Controllers
|
||||
Show old = await Get(obj.Slug);
|
||||
if (old != null)
|
||||
return old.ID;
|
||||
return await Create(obj);
|
||||
try
|
||||
{
|
||||
return await Create(obj);
|
||||
}
|
||||
catch (DuplicatedItemException)
|
||||
{
|
||||
old = await Get(obj.Slug);
|
||||
if (old == null)
|
||||
throw new SystemException("Unknown database state.");
|
||||
return old.ID;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Edit(Show edited, bool resetOld)
|
||||
|
@ -79,7 +79,17 @@ namespace Kyoo.Controllers
|
||||
Studio old = await Get(obj.Slug);
|
||||
if (old != null)
|
||||
return old.ID;
|
||||
return await Create(obj);
|
||||
try
|
||||
{
|
||||
return await Create(obj);
|
||||
}
|
||||
catch (DuplicatedItemException)
|
||||
{
|
||||
old = await Get(obj.Slug);
|
||||
if (old == null)
|
||||
throw new SystemException("Unknown database state.");
|
||||
return old.ID;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Edit(Studio edited, bool resetOld)
|
||||
|
Loading…
x
Reference in New Issue
Block a user