mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-11-24 08:46:48 +08:00
Fixes distributed lock record creation issue if already exists.
Fixes #6784
This commit is contained in:
@@ -148,8 +148,11 @@ 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.
|
||||
foreach (var expiredRecord in records) {
|
||||
repository.Delete(expiredRecord);
|
||||
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.
|
||||
@@ -220,4 +223,4 @@ namespace Orchard.Tasks.Locking.Services {
|
||||
return String.Format("DistributedLock:{0}:{1}", _shellSettings.Name, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user