Skip to content

Commit

Permalink
analizators/U2U1210
Browse files Browse the repository at this point in the history
  • Loading branch information
SuhorukovAnton committed Jan 19, 2022
1 parent 78047d3 commit 769fc55
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 29 deletions.
10 changes: 8 additions & 2 deletions products/ASC.Files/Core/Core/Dao/TeamlabDao/FileDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,10 @@ private void DeleteFile(int fileId, bool deleteFolder)

tx.Commit();

fromFolders.ForEach(folderId => RecalculateFilesCount(folderId));
foreach(var folderId in fromFolders)
{
RecalculateFilesCount(folderId);
}

if (deleteFolder)
DeleteFolder(fileId);
Expand Down Expand Up @@ -770,7 +773,10 @@ public int MoveFile(int fileId, int toFolderId)
FilesDbContext.SaveChanges();
tx.Commit();

fromFolders.ForEach(folderId => RecalculateFilesCount(folderId));
foreach(var folderId in fromFolders)
{
RecalculateFilesCount(folderId);
}
RecalculateFilesCount(toFolderId);
}

Expand Down
11 changes: 7 additions & 4 deletions products/ASC.Files/Core/Core/Dao/TeamlabDao/FolderDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -657,14 +657,17 @@ public IDictionary<int, string> CanMoveOrCopy(int[] folderIds, int to)

if (conflict != 0)
{
FilesDbContext.Files
var files = FilesDbContext.Files
.AsNoTracking()
.Join(FilesDbContext.Files, f1 => f1.Title.ToLower(), f2 => f2.Title.ToLower(), (f1, f2) => new { f1, f2 })
.Where(r => r.f1.TenantId == TenantID && r.f1.CurrentVersion && r.f1.FolderId == folderId)
.Where(r => r.f2.TenantId == TenantID && r.f2.CurrentVersion && r.f2.FolderId == conflict)
.Select(r => r.f1)
.ToList()
.ForEach(r => result[r.Id] = r.Title);
.Select(r => r.f1);

foreach (var file in files)
{
result[file.Id] = file.Title;
}

var childs = Query(FilesDbContext.Folders)
.AsNoTracking()
Expand Down
2 changes: 1 addition & 1 deletion products/ASC.Files/Core/Core/Dao/TeamlabDao/TagDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ public IEnumerable<Tag> GetNewTags(Guid subject, Folder<T> parentFolder, bool de
var monitorFolderIdsInt = monitorFolderIds.OfType<int>().ToList();
var subFoldersSqlQuery = getFolderQuery(FilesDbContext, monitorFolderIdsInt, deepSearch);

monitorFolderIds = monitorFolderIds.Concat(subFoldersSqlQuery.ToList().ConvertAll(r => (object)r));
monitorFolderIds = monitorFolderIds.Concat(subFoldersSqlQuery.Select(r => (object)r));

var monitorFolderIdsStrings = monitorFolderIds.Select(r => r.ToString()).ToList();

Expand Down
6 changes: 5 additions & 1 deletion products/ASC.Files/Core/Core/FilesIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ internal static Dictionary<object, IFileSecurity> GetFileSecurity(Dictionary<str
if (provider == null) continue;

var data = provider.GetFileSecurity(grouping.ToDictionary(r => r.Key, r => r.Value));
data.ToList().ForEach(x => result.Add(x.Key, x.Value));

foreach(var d in data)
{
result.Add(d.Key, d.Value);
}
}

return result;
Expand Down
25 changes: 13 additions & 12 deletions products/ASC.Files/Core/Core/Thirdparty/CrossDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ public File<TTo> PerformCrossDaoFileCopy<TFrom, TTo>(

if (deleteSourceFile)
{
if (fromFileShareRecords.Any())
fromFileShareRecords.ToList().ForEach(x =>
{
x.EntryId = toFile.ID;
securityDao.SetShare(x);
});
if (fromFileShareRecords.Any())
{
foreach (var record in fromFileShareRecords)
{
record.EntryId = toFile.ID;
securityDao.SetShare(record);
}
}

var fromFileTags = fromFileNewTags;
if (fromFileLockTag != null) fromFileTags.Add(fromFileLockTag);
Expand Down Expand Up @@ -167,12 +169,11 @@ public Folder<TTo> PerformCrossDaoFolderCopy<TFrom, TTo>
.Where(x => x.EntryType == FileEntryType.Folder);

if (fromFileShareRecords.Any())
{
fromFileShareRecords.ToList().ForEach(x =>
{
x.EntryId = toFolderId;
securityDao.SetShare(x);
});
{
foreach(var record in fromFileShareRecords){
record.EntryId = toFolderId;
securityDao.SetShare(record);
}
}

var tagDao = ServiceProvider.GetService<ITagDao<TFrom>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,17 @@ public IDaoSelector GetSelector(string id)

protected void SetSharedProperty(IEnumerable<FileEntry<string>> entries)
{
SecurityDao.GetPureShareRecords(entries.ToArray())
var ids = SecurityDao.GetPureShareRecords(entries.ToArray())
//.Where(x => x.Owner == SecurityContext.CurrentAccount.ID)
.Select(x => x.EntryId).Distinct().ToList()
.ForEach(id =>
{
var firstEntry = entries.FirstOrDefault(y => y.ID.Equals(id));
if (firstEntry != null)
firstEntry.Shared = true;
});
.Select(x => x.EntryId).Distinct();

foreach(var id in ids)
{
var firstEntry = entries.FirstOrDefault(y => y.ID.Equals(id));

if (firstEntry != null)
firstEntry.Shared = true;
}
}

protected IEnumerable<IDaoSelector> GetSelectors()
Expand Down

0 comments on commit 769fc55

Please sign in to comment.