Random Stuff (#3798)

This commit is contained in:
Joe Milazzo 2025-05-10 15:57:14 -06:00 committed by GitHub
parent 574cf4b78e
commit 70f00895e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
63 changed files with 659 additions and 567 deletions

View file

@ -226,7 +226,7 @@ public class ExternalMetadataService : IExternalMetadataService
AlternativeNames = altNames.Where(s => !string.IsNullOrEmpty(s)).ToList(),
Year = series.Metadata.ReleaseYear,
AniListId = potentialAnilistId ?? ScrobblingService.GetAniListId(series),
MalId = potentialMalId ?? ScrobblingService.GetMalId(series),
MalId = potentialMalId ?? ScrobblingService.GetMalId(series)
};
var token = (await _unitOfWork.UserRepository.GetDefaultAdminUser()).AniListAccessToken;
@ -792,7 +792,7 @@ public class ExternalMetadataService : IExternalMetadataService
var characters = externalCharacters
.Select(w => new PersonDto()
{
Name = w.Name,
Name = w.Name.Trim(),
AniListId = ScrobblingService.ExtractId<int>(w.Url, ScrobblingService.AniListCharacterWebsite),
Description = StringHelper.CorrectUrls(StringHelper.RemoveSourceInDescription(StringHelper.SquashBreaklines(w.Description))),
})
@ -873,7 +873,7 @@ public class ExternalMetadataService : IExternalMetadataService
var artists = upstreamArtists
.Select(w => new PersonDto()
{
Name = w.Name,
Name = w.Name.Trim(),
AniListId = ScrobblingService.ExtractId<int>(w.Url, ScrobblingService.AniListStaffWebsite),
Description = StringHelper.CorrectUrls(StringHelper.RemoveSourceInDescription(StringHelper.SquashBreaklines(w.Description))),
})
@ -929,7 +929,7 @@ public class ExternalMetadataService : IExternalMetadataService
var writers = upstreamWriters
.Select(w => new PersonDto()
{
Name = w.Name,
Name = w.Name.Trim(),
AniListId = ScrobblingService.ExtractId<int>(w.Url, ScrobblingService.AniListStaffWebsite),
Description = StringHelper.CorrectUrls(StringHelper.RemoveSourceInDescription(StringHelper.SquashBreaklines(w.Description))),
})
@ -1353,7 +1353,7 @@ public class ExternalMetadataService : IExternalMetadataService
var people = staff!
.Select(w => new PersonDto()
{
Name = w,
Name = w.Trim(),
})
.Concat(chapter.People
.Where(p => p.Role == role)

View file

@ -501,7 +501,7 @@ public class CoverDbService : ICoverDbService
else
{
_directoryService.DeleteFiles([tempFullPath]);
person.CoverImage = Path.GetFileName(existingPath);
return;
}
}
else
@ -651,6 +651,7 @@ public class CoverDbService : ICoverDbService
else
{
_directoryService.DeleteFiles([tempFullPath]);
return;
}
chapter.CoverImage = finalFileName;

View file

@ -310,7 +310,7 @@ public class LibraryWatcher : ILibraryWatcher
if (rootFolder.Count == 0) return string.Empty;
// Select the first folder and join with library folder, this should give us the folder to scan.
return Parser.Parser.NormalizePath(_directoryService.FileSystem.Path.Join(libraryFolder, rootFolder[rootFolder.Count - 1]));
return Parser.Parser.NormalizePath(_directoryService.FileSystem.Path.Join(libraryFolder, rootFolder[^1]));
}

View file

@ -52,6 +52,7 @@ public interface IVersionUpdaterService
Task PushUpdate(UpdateNotificationDto update);
Task<IList<UpdateNotificationDto>> GetAllReleases(int count = 0);
Task<int> GetNumberOfReleasesBehind(bool stableOnly = false);
void BustGithubCache();
}
@ -384,7 +385,7 @@ public partial class VersionUpdaterService : IVersionUpdaterService
if (DateTime.UtcNow - fileInfo.LastWriteTimeUtc <= CacheDuration)
{
var cachedData = await File.ReadAllTextAsync(_cacheLatestReleaseFilePath);
return System.Text.Json.JsonSerializer.Deserialize<UpdateNotificationDto>(cachedData);
return JsonSerializer.Deserialize<UpdateNotificationDto>(cachedData);
}
return null;
@ -407,7 +408,7 @@ public partial class VersionUpdaterService : IVersionUpdaterService
{
try
{
var json = System.Text.Json.JsonSerializer.Serialize(update, JsonOptions);
var json = JsonSerializer.Serialize(update, JsonOptions);
await File.WriteAllTextAsync(_cacheLatestReleaseFilePath, json);
}
catch (Exception ex)
@ -446,6 +447,21 @@ public partial class VersionUpdaterService : IVersionUpdaterService
.Count(u => u.IsReleaseNewer);
}
/// <summary>
/// Clears the Github cache
/// </summary>
public void BustGithubCache()
{
try
{
File.Delete(_cacheFilePath);
File.Delete(_cacheLatestReleaseFilePath);
} catch (Exception ex)
{
_logger.LogError(ex, "Failed to clear Github cache");
}
}
private UpdateNotificationDto? CreateDto(GithubReleaseMetadata? update)
{
if (update == null || string.IsNullOrEmpty(update.Tag_Name)) return null;