Fixed: Rare timing issue on first-use causing duplicate naming config (#2790)

Fixes #2773
pull/2/head
Qstick 7 years ago committed by Leonardo Galli
parent 0d5c71d205
commit 009abaf9be

@ -0,0 +1,15 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(148)]
public class remove_extra_naming_config : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
// Remove all but 1 NamingConfig
Execute.Sql("DELETE FROM NamingConfig WHERE ID NOT IN(SELECT ID FROM NamingConfig LIMIT 1)");
}
}
}

@ -125,6 +125,7 @@
<Compile Include="Authentication\UserRepository.cs" />
<Compile Include="Authentication\UserService.cs" />
<Compile Include="Datastore\Migration\123_create_netimport_table.cs" />
<Compile Include="Datastore\Migration\148_remove_extra_naming_config.cs" />
<Compile Include="Datastore\Migration\146_naming_config_colon_replacement_format.cs" />
<Compile Include="Datastore\Migration\143_clean_core_tv.cs" />
<Compile Include="Datastore\Migration\142_movie_extras.cs" />

@ -21,8 +21,16 @@ namespace NzbDrone.Core.Organizer
if (config == null)
{
_repository.Insert(NamingConfig.Default);
config = _repository.Single();
lock (_repository)
{
config = _repository.SingleOrDefault();
if (config == null)
{
_repository.Insert(NamingConfig.Default);
config = _repository.Single();
}
}
}
return config;
@ -33,4 +41,4 @@ namespace NzbDrone.Core.Organizer
_repository.Upsert(namingConfig);
}
}
}
}

Loading…
Cancel
Save