Merge pull request #1223 from ONLYOFFICE/bugfix/60994

fix Bug 60994
This commit is contained in:
Pavel Bannov 2023-02-22 13:02:07 +03:00 committed by GitHub
commit ef618f534e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -80,7 +80,7 @@ public class FileMarker
private readonly AuthContext _authContext;
private readonly IServiceProvider _serviceProvider;
private readonly FilesSettingsHelper _filesSettingsHelper;
private static readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1);
public FileMarker(
TenantManager tenantManager,
UserManager userManager,
@ -351,30 +351,41 @@ public class FileMarker
var tagDao = _daoFactory.GetTagDao<T>();
var newTags = new List<Tag>();
var updateTags = new List<Tag>();
foreach (var userID in userEntriesData.Keys)
try
{
if (await tagDao.GetNewTagsAsync(userID, obj.FileEntry).AnyAsync())
await _semaphore.WaitAsync();
foreach (var userID in userEntriesData.Keys)
{
continue;
if (await tagDao.GetNewTagsAsync(userID, obj.FileEntry).AnyAsync())
{
continue;
}
var entries = userEntriesData[userID].Distinct().ToList();
await GetNewTagsAsync(userID, entries.OfType<FileEntry<int>>().ToList());
await GetNewTagsAsync(userID, entries.OfType<FileEntry<string>>().ToList());
}
if (updateTags.Count > 0)
{
await tagDao.UpdateNewTags(updateTags, obj.CurrentAccountId);
}
if (newTags.Count > 0)
{
await tagDao.SaveTags(newTags, obj.CurrentAccountId);
}
var entries = userEntriesData[userID].Distinct().ToList();
await GetNewTagsAsync(userID, entries.OfType<FileEntry<int>>().ToList());
await GetNewTagsAsync(userID, entries.OfType<FileEntry<string>>().ToList());
}
if (updateTags.Count > 0)
catch
{
await tagDao.UpdateNewTags(updateTags, obj.CurrentAccountId);
throw;
}
if (newTags.Count > 0)
finally
{
await tagDao.SaveTags(newTags, obj.CurrentAccountId);
_semaphore.Release();
}
await Task.WhenAll(ExecMarkAsNewRequest(updateTags.Concat(newTags), socketManager));