private static List <PackedId> UpdateRelease(SqlConnection conn, Release release, ILogger log, ref long lastEpisodeTimestamp, TorrentsData existingTorrentIds)
        {
            log.LogInformation("++Updating the release entry...");
            var res = new List <PackedId>();

            using (var cmd = conn.CreateCommand())
            {
                cmd.CommandText = @"UPDATE Releases 
                                    SET Titles = @titles,
                                        Poster = @poster,
                                        LastModified = @lastmodified,
                                        StatusCode = @statuscode,
                                        Genres = @genres,
                                        Voicers = @voicers,
                                        Year = @year,
                                        Season = @season,
                                        Description = @description,
                                        Torrents = @torrents,
                                        Rating = @rating,
                                        Code = @code,
                                        Baka = @bakanim
                                    WHERE Id = @id
                                    SELECT Id FROM Episodes WHERE ReleaseId = @id";
                cmd.Parameters.AddWithValue("@id", release.id);
                cmd.Parameters.AddWithValue("@titles", JsonConvert.SerializeObject(release.names));
                cmd.Parameters.AddWithValue("@poster", release.poster);
                cmd.Parameters.AddWithValue("@lastmodified", release.LastModified);
                cmd.Parameters.AddWithValue("@statuscode", release.StatusCode);
                cmd.Parameters.AddWithValue("@genres", JsonConvert.SerializeObject(release.genres));
                cmd.Parameters.AddWithValue("@voicers", JsonConvert.SerializeObject(release.voices));
                cmd.Parameters.AddWithValue("@year", release.Year);
                cmd.Parameters.AddWithValue("@season", release.season);
                cmd.Parameters.AddWithValue("@description", release.description);
                cmd.Parameters.AddWithValue("@torrents", JsonConvert.SerializeObject(release.torrents));
                cmd.Parameters.AddWithValue("@rating", release.favorite.rating);
                cmd.Parameters.AddWithValue("@code", release.code);
                cmd.Parameters.AddWithValue("@bakanim", release.blockedInfo?.bakanim ?? false);
                using (var rdr = cmd.ExecuteReader())
                {
                    while (rdr.Read())
                    {
                        res.Add(PackedId.Unpack(rdr.GetInt32(0)));
                    }
                }
            }

            lastEpisodeTimestamp = CheckTimeStamp(lastEpisodeTimestamp, 36, "No usable timestamp for new episodes", log);

            SynchronizeTorrentIndex(conn, release, existingTorrentIds ?? GetTorrentIds(conn, release.id), log);

            log.LogInformation($"++Update complete. {res.Count} episodes found.");
            return(res);
        }
        private static void DeleteEpisode(SqlConnection conn, PackedId episode, ILogger log)
        {
            var epDbId = episode.Pack();

            log.LogInformation($"++-Deleting an obsolete episode {episode.EpisodeId} of release {episode.ReleaseId} (DB id {epDbId}).");
            using (var cmd = conn.CreateCommand())
            {
                cmd.CommandText = "DELETE FROM Episodes WHERE Id=@id";
                cmd.Parameters.AddWithValue("@id", epDbId);
                var rows = cmd.ExecuteNonQuery();
                log.LogInformation($"++- ==> {(rows == 1 ? "OK" : "FAILURE")}.");
            }
        }