Fixes distributed lock record creation issue if already exists.

Fixes #6784
This commit is contained in:
jtkech
2016-04-20 18:00:03 +02:00
committed by Sebastien Ros
parent b8e138b2d5
commit 43e1040661

View File

@@ -148,9 +148,12 @@ namespace Orchard.Tasks.Locking.Services {
// No record matched the criteria, but at least one expired record with the specified name was found.
// Delete the expired records before creating a new one. In theory no more than one record can exist
// due to the unique key constraint on the 'Name' column, it won't hurt to work on a collection.
if (records.Any()) {
foreach (var expiredRecord in records) {
repository.Delete(expiredRecord);
}
repository.Flush();
}
// No valid record existed, so we're good to create a new one.
Logger.Debug("No valid record was found for lock '{0}'; creating a new record.", internalName);