public async Task <IActionResult> HomePage() { var user = User.FindFirstValue(ClaimTypes.Name); var files = (await _sql.AllAuthoredFiles()) .Where(af => af.Author == user) .Select(af => new { Size = af.Size.FileSizeToString(), OriginalSize = af.Size, Name = af.OriginalFileName, MangledName = af.MungedName, UploadedDate = af.LastTouched }) .OrderBy(f => f.Name) .ThenBy(f => f.UploadedDate) .ToList(); var result = HomePageTemplate(new { User = user, TotalUsage = files.Select(f => f.OriginalSize).Sum().ToFileSizeString(), WabbajackFiles = files.Where(f => f.Name.EndsWith(Consts.ModListExtensionString)), OtherFiles = files.Where(f => !f.Name.EndsWith(Consts.ModListExtensionString)) }); return(new ContentResult { ContentType = "text/html", StatusCode = (int)HttpStatusCode.OK, Content = await result }); }
public async Task <ContentResult> UploadedFilesGet() { var files = await _sql.AllAuthoredFiles(); var response = HandleGetListTemplate(new { files }); return(new ContentResult { ContentType = "text/html", StatusCode = (int)HttpStatusCode.OK, Content = response }); }
public async Task <(string[] CDNDelete, string[] SQLDelete, string[] CDNNotDeleted, string[] SQLNotDeleted)> FindFilesToDelete() { var cdnNames = (await GetCDNMungedNames()).ToHashSet(); var usedNames = (await GetUsedCDNFiles()).ToHashSet(); var sqlFiles = (await _sql.AllAuthoredFiles()).ToDictionary(f => f.MungedName); var keep = GetKeepList(cdnNames, usedNames, sqlFiles).ToHashSet(); var cdnDelete = cdnNames.Where(h => !keep.Contains(h)).ToArray(); var sqlDelete = sqlFiles.Where(s => !keep.Contains(s.Value.MungedName)) .Select(s => s.Value.ServerAssignedUniqueId) .ToArray(); var cdnhs = cdnDelete.ToHashSet(); var notDeletedCDN = cdnNames.Where(f => !cdnhs.Contains(f)).ToArray(); var sqlhs = sqlDelete.ToHashSet(); var sqlNotDeleted = sqlFiles.Where(f => !sqlDelete.Contains(f.Value.ServerAssignedUniqueId)) .Select(f => f.Value.MungedName) .ToArray(); return(cdnDelete, sqlDelete, notDeletedCDN, sqlNotDeleted); }