Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.
C# annotationscbzcomicinfocomicscomics-readercross-platformcsharpepubepub-readerfreelinuxmangamedia-servermetadataopdsopds-feedpdfself-hostedubooquitywindows
Don't log exceptions to Sentry when debugging locally. Fixed a constraint issue with collection tags that prevented deleting series. Ensure when we scan we add SeriesMetadata objects to existing series. (#265)
Joseph Milazzoaa7439178cfc
diff --git a/API/Controllers/LibraryController.cs b/API/Controllers/LibraryController.csindex 4867be3d8..72a91f1fb 100644--- a/API/Controllers/LibraryController.cs+++ b/API/Controllers/LibraryController.cs@@ -172,10 +172,11 @@ namespace API.Controllersvar username = User.GetUsername();_logger.LogInformation("Library {LibraryId} is being deleted by {UserName}", libraryId, username);var series = await _unitOfWork.SeriesRepository.GetSeriesForLibraryIdAsync(libraryId);+ var seriesIds = series.Select(x => x.Id).ToArray();var chapterIds =- await _unitOfWork.SeriesRepository.GetChapterIdsForSeriesAsync(series.Select(x => x.Id).ToArray());- var result = await _unitOfWork.LibraryRepository.DeleteLibrary(libraryId);-+ await _unitOfWork.SeriesRepository.GetChapterIdsForSeriesAsync(seriesIds);++ var result = await _unitOfWork.LibraryRepository.DeleteLibrary(libraryId);if (result && chapterIds.Any()){_taskScheduler.CleanupChapters(chapterIds);diff --git a/API/Controllers/SeriesController.cs b/API/Controllers/SeriesController.csindex 320b08d6e..caa55b229 100644--- a/API/Controllers/SeriesController.cs+++ b/API/Controllers/SeriesController.cs@@ -59,7 +59,7 @@ namespace API.Controllersvar chapterIds = (await _unitOfWork.SeriesRepository.GetChapterIdsForSeriesAsync(new []{seriesId}));_logger.LogInformation("Series {SeriesId} is being deleted by {UserName}", seriesId, username);var result = await _unitOfWork.SeriesRepository.DeleteSeriesAsync(seriesId);-+if (result){_taskScheduler.CleanupChapters(chapterIds);diff --git a/API/Data/Migrations/20210519215934_CollectionTag.cs b/API/Data/Migrations/20210519215934_CollectionTag.csindex b6afc209e..b95a3bd9b 100644--- a/API/Data/Migrations/20210519215934_CollectionTag.cs+++ b/API/Data/Migrations/20210519215934_CollectionTag.cs@@ -65,7 +65,7 @@ namespace API.Data.Migrationscolumn: x => x.SeriesMetadatasId,principalTable: "SeriesMetadata",principalColumn: "Id",- onDelete: ReferentialAction.NoAction);+ onDelete: ReferentialAction.Cascade);});migrationBuilder.CreateIndex(diff --git a/API/Data/Migrations/DataContextModelSnapshot.cs b/API/Data/Migrations/DataContextModelSnapshot.csindex fafd70de0..f14402ece 100644--- a/API/Data/Migrations/DataContextModelSnapshot.cs+++ b/API/Data/Migrations/DataContextModelSnapshot.cs@@ -148,9 +148,6 @@ namespace API.Data.Migrationsb.Property<bool>("BookReaderTapToPaginate").HasColumnType("INTEGER");- b.Property<int>("BookReaderReadingDirection")- .HasColumnType("INTEGER");-b.Property<int>("PageSplitOption").HasColumnType("INTEGER");diff --git a/API/Program.cs b/API/Program.csindex d9715c0f6..b2612efbe 100644--- a/API/Program.cs+++ b/API/Program.cs@@ -84,52 +84,56 @@ namespace APIoptions.Protocols = HttpProtocols.Http1AndHttp2;});});--- webBuilder.UseSentry(options =>++ var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");+ if (environment != Environments.Development){- options.Dsn = "https://[email protected]/5757423";- options.MaxBreadcrumbs = 200;- options.AttachStacktrace = true;- options.Debug = false;- options.SendDefaultPii = false;- options.DiagnosticLevel = SentryLevel.Debug;- options.ShutdownTimeout = TimeSpan.FromSeconds(5);- options.Release = BuildInfo.Version.ToString();- options.AddExceptionFilterForType<OutOfMemoryException>();- options.AddExceptionFilterForType<NetVips.VipsException>();- options.AddExceptionFilterForType<InvalidDataException>();- options.AddExceptionFilterForType<KavitaException>();-- options.BeforeSend = sentryEvent =>+ webBuilder.UseSentry(options =>{- if (sentryEvent.Exception != null- && sentryEvent.Exception.Message.Contains("[GetCoverImage] This archive cannot be read:")- && sentryEvent.Exception.Message.Contains("[BookService] "))- {- return null; // Don't send this event to Sentry- }+ options.Dsn = "https://[email protected]/5757423";+ options.MaxBreadcrumbs = 200;+ options.AttachStacktrace = true;+ options.Debug = false;+ options.SendDefaultPii = false;+ options.DiagnosticLevel = SentryLevel.Debug;+ options.ShutdownTimeout = TimeSpan.FromSeconds(5);+ options.Release = BuildInfo.Version.ToString();+ options.AddExceptionFilterForType<OutOfMemoryException>();+ options.AddExceptionFilterForType<NetVips.VipsException>();+ options.AddExceptionFilterForType<InvalidDataException>();+ options.AddExceptionFilterForType<KavitaException>();- sentryEvent.ServerName = null; // Never send Server Name to Sentry- return sentryEvent;- };-- options.ConfigureScope(scope =>- {- scope.User = new User()+ options.BeforeSend = sentryEvent =>{- Id = HashUtil.AnonymousToken()+ if (sentryEvent.Exception != null+ && sentryEvent.Exception.Message.Contains("[GetCoverImage] This archive cannot be read:")+ && sentryEvent.Exception.Message.Contains("[BookService] "))+ {+ return null; // Don't send this event to Sentry+ }++ sentryEvent.ServerName = null; // Never send Server Name to Sentry+ return sentryEvent;};- scope.Contexts.App.Name = BuildInfo.AppName;- scope.Contexts.App.Version = BuildInfo.Version.ToString();- scope.Contexts.App.StartTime = DateTime.UtcNow;- scope.Contexts.App.Hash = HashUtil.AnonymousToken();- scope.Contexts.App.Build = BuildInfo.Release;- scope.SetTag("culture", Thread.CurrentThread.CurrentCulture.Name);- scope.SetTag("branch", BuildInfo.Branch);- });++ options.ConfigureScope(scope =>+ {+ scope.User = new User()+ {+ Id = HashUtil.AnonymousToken()+ };+ scope.Contexts.App.Name = BuildInfo.AppName;+ scope.Contexts.App.Version = BuildInfo.Version.ToString();+ scope.Contexts.App.StartTime = DateTime.UtcNow;+ scope.Contexts.App.Hash = HashUtil.AnonymousToken();+ scope.Contexts.App.Build = BuildInfo.Release;+ scope.SetTag("culture", Thread.CurrentThread.CurrentCulture.Name);+ scope.SetTag("branch", BuildInfo.Branch);+ });- });+ });+ }+webBuilder.UseStartup<Startup>();});}diff --git a/API/Services/Tasks/ScannerService.cs b/API/Services/Tasks/ScannerService.csindex 12f30afad..e22803c4b 100644--- a/API/Services/Tasks/ScannerService.cs+++ b/API/Services/Tasks/ScannerService.cs@@ -228,6 +228,7 @@ namespace API.Services.TasksexistingSeries.NormalizedName = Parser.Parser.Normalize(existingSeries.Name);existingSeries.OriginalName ??= infos[0].Series;+ existingSeries.Metadata ??= DbFactory.SeriesMetadata(new List<CollectionTag>());}// Now, we only have to deal with series that exist on disk. Let's recalculate the volumes for each seriesdiff --git a/API/Startup.cs b/API/Startup.csindex 29cce3832..82fd667a3 100644--- a/API/Startup.cs+++ b/API/Startup.cs@@ -83,6 +83,7 @@ namespace APIapp.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "API v1"));app.UseHangfireDashboard();}+app.UseResponseCompression();app.UseForwardedHeaders();@@ -132,9 +133,9 @@ namespace APIapplicationLifetime.ApplicationStopping.Register(OnShutdown);applicationLifetime.ApplicationStarted.Register(() =>{- Console.WriteLine("Kavita - v" + BuildInfo.Version);+ Console.WriteLine($"Kavita - v{BuildInfo.Version}");});-+// Any services that should be bootstrapped go heretaskScheduler.ScheduleTasks();}diff --git a/Kavita.Common/EnvironmentInfo/BuildInfo.cs b/Kavita.Common/EnvironmentInfo/BuildInfo.csindex 32b3e60d8..a1f72195c 100644--- a/Kavita.Common/EnvironmentInfo/BuildInfo.cs+++ b/Kavita.Common/EnvironmentInfo/BuildInfo.cs@@ -20,7 +20,7 @@ namespace Kavita.Common.EnvironmentInfovar config = attributes.OfType<AssemblyConfigurationAttribute>().FirstOrDefault();if (config != null){- Branch = config.Configuration;+ Branch = config.Configuration; // TODO: This is not helpful, better to have main/develop branch}Release = $"{Version}-{Branch}";