mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-05-24 00:52:23 -04:00
In Progress Query Update (#145)
* Fixed a bug where chapter cover images weren't being updated due to a missed not. * Removed a piece of code that was needed for upgrading, since all beta users agreed to wipe db. * Fixed InProgress to properly respect order and show more recent activity first. Issue is with IEntityDate LastModified not updating in DataContext. * Updated dependencies to lastest stable. * LastModified on Volumes wasn't updating, validated it does update when data is changed.
This commit is contained in:
parent
ca5c666b7b
commit
7790cf31fd
@ -7,14 +7,14 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="NSubstitute" Version="4.2.2" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="1.3.0">
|
||||
<PackageReference Include="coverlet.collector" Version="3.0.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
|
@ -11,30 +11,30 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.0" />
|
||||
<PackageReference Include="Hangfire" Version="1.7.18" />
|
||||
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.18" />
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
|
||||
<PackageReference Include="Hangfire" Version="1.7.20" />
|
||||
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.20" />
|
||||
<PackageReference Include="Hangfire.MaximumConcurrentExecutions" Version="1.1.0" />
|
||||
<PackageReference Include="Hangfire.MemoryStorage.Core" Version="1.4.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.1">
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.4" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
|
||||
<PackageReference Include="NetVips" Version="1.2.4" />
|
||||
<PackageReference Include="NetVips.Native" Version="8.10.5.1" />
|
||||
<PackageReference Include="NetVips" Version="2.0.0" />
|
||||
<PackageReference Include="NetVips.Native" Version="8.10.6" />
|
||||
<PackageReference Include="NReco.Logging.File" Version="1.1.1" />
|
||||
<PackageReference Include="SharpCompress" Version="0.28.1" />
|
||||
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.16.0.25740">
|
||||
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.20.0.28934">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.8.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.1" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.10.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -22,7 +22,7 @@ namespace API.Controllers
|
||||
const string format = "jpeg";
|
||||
|
||||
Response.AddCacheHeader(content);
|
||||
return File(content, "image/" + format);
|
||||
return File(content, "image/" + format, $"chapterId");
|
||||
}
|
||||
|
||||
[HttpGet("volume-cover")]
|
||||
@ -33,7 +33,7 @@ namespace API.Controllers
|
||||
const string format = "jpeg";
|
||||
|
||||
Response.AddCacheHeader(content);
|
||||
return File(content, "image/" + format);
|
||||
return File(content, "image/" + format, $"volumeId");
|
||||
}
|
||||
|
||||
[HttpGet("series-cover")]
|
||||
@ -44,7 +44,7 @@ namespace API.Controllers
|
||||
const string format = "jpeg";
|
||||
|
||||
Response.AddCacheHeader(content);
|
||||
return File(content, "image/" + format);
|
||||
return File(content, "image/" + format, $"seriesId");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -19,14 +20,16 @@ namespace API.Controllers
|
||||
private readonly ICacheService _cacheService;
|
||||
private readonly ILogger<ReaderController> _logger;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly DataContext _dataContext;
|
||||
|
||||
public ReaderController(IDirectoryService directoryService, ICacheService cacheService,
|
||||
ILogger<ReaderController> logger, IUnitOfWork unitOfWork)
|
||||
ILogger<ReaderController> logger, IUnitOfWork unitOfWork, DataContext dataContext)
|
||||
{
|
||||
_directoryService = directoryService;
|
||||
_cacheService = cacheService;
|
||||
_logger = logger;
|
||||
_unitOfWork = unitOfWork;
|
||||
_dataContext = dataContext;
|
||||
}
|
||||
|
||||
[HttpGet("image")]
|
||||
@ -218,7 +221,8 @@ namespace API.Controllers
|
||||
PagesRead = bookmarkDto.PageNum,
|
||||
VolumeId = bookmarkDto.VolumeId,
|
||||
SeriesId = bookmarkDto.SeriesId,
|
||||
ChapterId = bookmarkDto.ChapterId
|
||||
ChapterId = bookmarkDto.ChapterId,
|
||||
LastModified = DateTime.Now
|
||||
});
|
||||
}
|
||||
else
|
||||
@ -226,8 +230,9 @@ namespace API.Controllers
|
||||
userProgress.PagesRead = bookmarkDto.PageNum;
|
||||
userProgress.SeriesId = bookmarkDto.SeriesId;
|
||||
userProgress.VolumeId = bookmarkDto.VolumeId;
|
||||
userProgress.LastModified = DateTime.Now;
|
||||
}
|
||||
|
||||
|
||||
_unitOfWork.UserRepository.Update(user);
|
||||
|
||||
if (await _unitOfWork.Complete())
|
||||
|
@ -47,11 +47,16 @@ namespace API.Data
|
||||
.HasForeignKey(ur => ur.RoleId)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
|
||||
void OnEntityTracked(object sender, EntityTrackedEventArgs e)
|
||||
{
|
||||
if (!e.FromQuery && e.Entry.State == EntityState.Added && e.Entry.Entity is IEntityDate entity)
|
||||
{
|
||||
entity.Created = DateTime.Now;
|
||||
entity.LastModified = DateTime.Now;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void OnEntityStateChanged(object sender, EntityStateChangedEventArgs e)
|
||||
|
@ -315,13 +315,13 @@ namespace API.Data
|
||||
&& s.PagesRead > 0
|
||||
&& s.PagesRead < s.Series.Pages
|
||||
&& (libraryId <= 0 || s.Series.LibraryId == libraryId))
|
||||
.OrderByDescending(s => s.LastModified)
|
||||
.Take(limit)
|
||||
.Select(s => s.Series.Id);
|
||||
|
||||
|
||||
var series = await _context.Series
|
||||
.Where(s => seriesWithProgress.Contains(s.Id))
|
||||
.OrderByDescending(s => s.LastModified)
|
||||
.Take(limit)
|
||||
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
|
Binary file not shown.
@ -10,9 +10,9 @@ namespace API.Extensions
|
||||
return comparison.Equals(fileInfo.LastWriteTime);
|
||||
}
|
||||
|
||||
public static bool IsLastWriteOlder(this FileInfo fileInfo, DateTime comparison)
|
||||
public static bool IsLastWriteLessThan(this FileInfo fileInfo, DateTime comparison)
|
||||
{
|
||||
return comparison > fileInfo.LastWriteTime;
|
||||
return fileInfo.LastWriteTime < comparison;
|
||||
}
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ namespace API.Services
|
||||
public void UpdateMetadata(Chapter chapter, bool forceUpdate)
|
||||
{
|
||||
var firstFile = chapter.Files.OrderBy(x => x.Chapter).FirstOrDefault();
|
||||
if (ShouldFindCoverImage(chapter.CoverImage, forceUpdate) && firstFile != null && new FileInfo(firstFile.FilePath).IsLastWriteOlder(firstFile.LastModified))
|
||||
if (ShouldFindCoverImage(chapter.CoverImage, forceUpdate) && firstFile != null && !new FileInfo(firstFile.FilePath).IsLastWriteLessThan(firstFile.LastModified))
|
||||
{
|
||||
chapter.Files ??= new List<MangaFile>();
|
||||
chapter.CoverImage = _archiveService.GetCoverImage(firstFile.FilePath, true);
|
||||
@ -53,7 +53,7 @@ namespace API.Services
|
||||
// Skip calculating Cover Image (I/O) if the chapter already has it set
|
||||
if (firstChapter == null || ShouldFindCoverImage(firstChapter.CoverImage))
|
||||
{
|
||||
if (firstFile != null && !new FileInfo(firstFile.FilePath).IsLastWriteOlder(firstFile.LastModified))
|
||||
if (firstFile != null && !new FileInfo(firstFile.FilePath).IsLastWriteLessThan(firstFile.LastModified))
|
||||
{
|
||||
volume.CoverImage = _archiveService.GetCoverImage(firstFile.FilePath, true);
|
||||
}
|
||||
|
@ -261,18 +261,6 @@ namespace API.Services.Tasks
|
||||
var chapter = info.IsSpecial ? volume.Chapters.SingleOrDefault(c => c.Range == info.Filename || (c.Files.Select(f => f.FilePath).Contains(info.FullFilePath)))
|
||||
: volume.Chapters.SingleOrDefault(c => c.Range == info.Chapters);
|
||||
|
||||
if (info.IsSpecial && chapter != null && chapter.Files.Count > 1)
|
||||
{
|
||||
var fileToKeep = chapter.Files.SingleOrDefault(f => f.FilePath == info.FullFilePath);
|
||||
if (fileToKeep != null)
|
||||
{
|
||||
chapter.Files = new List<MangaFile>()
|
||||
{
|
||||
fileToKeep
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (chapter == null)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user