Files: refactoring
This commit is contained in:
parent
b294b557b0
commit
7dfaf60592
@ -173,11 +173,9 @@ internal class TagDao<T> : AbstractDao, ITagDao<T>
|
||||
}
|
||||
}
|
||||
|
||||
if (fileEntries.Any())
|
||||
if (filesId.Any() || foldersId.Any())
|
||||
{
|
||||
var fromQuery = await FromQueryAsync(_getTagsQuery(FilesDbContext, TenantID, subject, tagType, filesId, foldersId))
|
||||
.ToListAsync()
|
||||
;
|
||||
var fromQuery = await FromQueryAsync(_getTagsQuery(FilesDbContext, TenantID, subject, tagType, filesId, foldersId)).ToListAsync();
|
||||
|
||||
return fromQuery
|
||||
.GroupBy(r => r.EntryId)
|
||||
|
@ -238,10 +238,10 @@ public class FileStorageService<T> //: IFileStorageService
|
||||
}));
|
||||
}
|
||||
|
||||
public async Task<DataWrapper<T>> GetFolderItemsAsync(T parentId, int from, int count, FilterType filter, bool subjectGroup, string ssubject, string searchText, bool searchInContent, bool withSubfolders, OrderBy orderBy,
|
||||
public Task<DataWrapper<T>> GetFolderItemsAsync(T parentId, int from, int count, FilterType filter, bool subjectGroup, string ssubject, string searchText, bool searchInContent, bool withSubfolders, OrderBy orderBy,
|
||||
SearchArea searchArea = SearchArea.Active, IEnumerable<string> tagNames = null)
|
||||
{
|
||||
return await GetFolderItemsAsync(parentId, from, count, new[] { filter }, subjectGroup, ssubject, searchText, searchInContent, withSubfolders, orderBy, searchArea, tagNames);
|
||||
return GetFolderItemsAsync(parentId, from, count, new[] { filter }, subjectGroup, ssubject, searchText, searchInContent, withSubfolders, orderBy, searchArea, tagNames);
|
||||
}
|
||||
|
||||
public async Task<DataWrapper<T>> GetFolderItemsAsync(T parentId, int from, int count, IEnumerable<FilterType> filterTypes, bool subjectGroup, string ssubject, string searchText, bool searchInContent, bool withSubfolders, OrderBy orderBy,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -203,13 +203,6 @@ public class EntryStatusManager
|
||||
await t2;
|
||||
}
|
||||
|
||||
public async Task SetFileStatusAsyncEnumerable(IAsyncEnumerable<FileEntry> asyncEnumerableFiles)
|
||||
{
|
||||
var files = await asyncEnumerableFiles.ToListAsync();
|
||||
await SetFileStatusAsync(files.OfType<File<int>>().Where(r => r.Id != 0));
|
||||
await SetFileStatusAsync(files.OfType<File<string>>().Where(r => !string.IsNullOrEmpty(r.Id)));
|
||||
}
|
||||
|
||||
public async Task SetFileStatusAsync<T>(IEnumerable<File<T>> files)
|
||||
{
|
||||
if (!files.Any())
|
||||
@ -301,53 +294,6 @@ public class EntryStatusManager
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SetFileStatusAsyncEnumerable<T>(IAsyncEnumerable<File<T>> files)
|
||||
{
|
||||
var tagDao = _daoFactory.GetTagDao<T>();
|
||||
|
||||
var tags = await tagDao.GetTagsAsync(_authContext.CurrentAccount.ID, new[] { TagType.Favorite, TagType.Template, TagType.Locked }, files);
|
||||
var tagsNew = tagDao.GetNewTagsAsync(_authContext.CurrentAccount.ID, files);
|
||||
|
||||
await foreach (var file in files)
|
||||
{
|
||||
foreach (var t in tags)
|
||||
{
|
||||
if (!t.Key.Equals(file.Id))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (t.Value.Any(r => r.Type == TagType.Favorite))
|
||||
{
|
||||
file.IsFavorite = true;
|
||||
}
|
||||
|
||||
if (t.Value.Any(r => r.Type == TagType.Template))
|
||||
{
|
||||
file.IsTemplate = true;
|
||||
}
|
||||
|
||||
var lockedTag = t.Value.FirstOrDefault(r => r.Type == TagType.Locked);
|
||||
if (lockedTag != null)
|
||||
{
|
||||
var lockedBy = lockedTag.Owner;
|
||||
file.Locked = lockedBy != Guid.Empty;
|
||||
file.LockedBy = lockedBy != Guid.Empty && lockedBy != _authContext.CurrentAccount.ID
|
||||
? _global.GetUserName(lockedBy)
|
||||
: null;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (await tagsNew.AnyAsync(r => r.EntryId.Equals(file.Id)))
|
||||
{
|
||||
file.IsNew = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Scope]
|
||||
@ -815,9 +761,7 @@ public class EntryManager
|
||||
}
|
||||
|
||||
public async IAsyncEnumerable<Folder<string>> GetThirpartyFoldersAsyncEnumerable<T>(Folder<T> parent, string searchText = null)
|
||||
{
|
||||
var folderList = AsyncEnumerable.Empty<Folder<string>>();
|
||||
|
||||
{
|
||||
if ((parent.Id.Equals(_globalFolderHelper.FolderMy) || parent.Id.Equals(await _globalFolderHelper.FolderCommonAsync))
|
||||
&& _thirdpartyConfiguration.SupportInclusion(_daoFactory)
|
||||
&& (_filesSettingsHelper.EnableThirdParty
|
||||
@ -829,14 +773,8 @@ public class EntryManager
|
||||
yield break;
|
||||
}
|
||||
|
||||
var fileSecurity = _fileSecurity;
|
||||
|
||||
var providers = providerDao.GetProvidersInfoAsync(parent.RootFolderType, searchText);
|
||||
|
||||
folderList = providers
|
||||
.Select(providerInfo => GetFakeThirdpartyFolder(providerInfo, parent.Id.ToString()))
|
||||
.WhereAwait(async fake => await fileSecurity.CanReadAsync(fake));
|
||||
|
||||
//var securityDao = _daoFactory.GetSecurityDao<string>();
|
||||
//var pureShareRecords = securityDao.GetPureShareRecordsAsyncEnumerable(folderList);
|
||||
//var ids = pureShareRecords
|
||||
@ -845,7 +783,7 @@ public class EntryManager
|
||||
|
||||
//folderList.Intersect(ids, y => dfs);
|
||||
|
||||
|
||||
|
||||
//if (folderList.Count > 0)
|
||||
//{
|
||||
// var securityDao = _daoFactory.GetSecurityDao<string>();
|
||||
@ -857,13 +795,17 @@ public class EntryManager
|
||||
// await foreach (var id in ids)
|
||||
// {
|
||||
// folderList.First(y => y.Id.Equals(id)).Shared = true;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
await foreach (var e in folderList)
|
||||
{
|
||||
yield return e;
|
||||
// }
|
||||
//}
|
||||
|
||||
await foreach (var e in providers)
|
||||
{
|
||||
var fake = GetFakeThirdpartyFolder(e, parent.Id.ToString());
|
||||
if (await _fileSecurity.CanReadAsync(fake))
|
||||
{
|
||||
yield return fake;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -895,8 +895,9 @@ public class FileMarker
|
||||
return;
|
||||
}
|
||||
|
||||
var parentFolderTag = Equals(await _globalFolder.GetFolderShareAsync<T>(_daoFactory), parent.Id)
|
||||
? await tagDao.GetNewTagsAsync(_authContext.CurrentAccount.ID, await folderDao.GetFolderAsync(await _globalFolder.GetFolderShareAsync<T>(_daoFactory))).FirstOrDefaultAsync()
|
||||
var shareFolder = await _globalFolder.GetFolderShareAsync<T>(_daoFactory);
|
||||
var parentFolderTag = Equals(shareFolder, parent.Id)
|
||||
? await tagDao.GetNewTagsAsync(_authContext.CurrentAccount.ID, await folderDao.GetFolderAsync(shareFolder)).FirstOrDefaultAsync()
|
||||
: totalTags.FirstOrDefault(tag => tag.EntryType == FileEntryType.Folder && Equals(tag.EntryId, parent.Id));
|
||||
|
||||
totalTags = totalTags.Where(e => e != parentFolderTag).ToList();
|
||||
@ -941,7 +942,7 @@ public class FileMarker
|
||||
}
|
||||
else if (rootFolder.RootFolderType == FolderType.USER && !Equals(rootFolder.RootId, _globalFolder.GetFolderMy(this, _daoFactory)))
|
||||
{
|
||||
cacheFolderId = rootFolderId = await _globalFolder.GetFolderShareAsync<T>(_daoFactory);
|
||||
cacheFolderId = rootFolderId = shareFolder;
|
||||
}
|
||||
|
||||
if (rootFolderId != null)
|
||||
|
Loading…
Reference in New Issue
Block a user