Skip to content

Commit

Permalink
Images smaller than 512 bytes will be ignored
Browse files Browse the repository at this point in the history
They are probably thumnails.
  • Loading branch information
maforget committed May 20, 2024
1 parent 0d03dd7 commit ff00007
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected override void OnParse()
{
using (IItemLock<List<ProviderImageInfo>> itemLock = GetCachedFileList())
{
List<ProviderImageInfo> list = new List<ProviderImageInfo>(itemLock.Item.Where((ProviderImageInfo ii) => IsSupportedImage(ii.Name)));
List<ProviderImageInfo> list = new List<ProviderImageInfo>(itemLock.Item.Where((ProviderImageInfo ii) => IsSupportedImage(ii)));
list.Sort((a, b) => cYo.Common.Text.ExtendedStringComparer.Compare(a.Name, b.Name, ExtendedStringComparison.IgnoreCase));
foundImageList = list;
}
Expand Down
14 changes: 10 additions & 4 deletions ComicRack.Engine/IO/Provider/Readers/ComicProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,25 @@ protected virtual bool OnStoreInfo(ComicInfo comicInfo)
return false;
}

protected virtual bool IsSupportedImage(string file)
protected virtual bool IsSupportedImage(ProviderImageInfo file)
{
if(ShouldIgnoreFile(file))
if(IsImageThumnailFolder(file.Name) || IsFileTooSmall(file.Size))
return false;

string fileExt = Path.GetExtension(FileUtility.MakeValidFilename(file));
string fileExt = Path.GetExtension(FileUtility.MakeValidFilename(file.Name));
return supportedTypes.Any((string ext) => string.Equals(fileExt, "." + ext, StringComparison.OrdinalIgnoreCase));
}

private static bool ShouldIgnoreFile(string file)
private static bool IsImageThumnailFolder(string file)
{
string[] ignore = { ".DS_Store\\", "__MACOSX\\" };
return ignore.Any(item => file.Contains(item));
}

private static bool IsFileTooSmall(long size)
{
long minSize = 512;
return size < minSize;
}
}
}
2 changes: 1 addition & 1 deletion ComicRack.Engine/IO/Provider/Readers/WebComicProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public WebComicProvider()
base.DisableSidecar = true;
}

protected override bool IsSupportedImage(string file)
protected override bool IsSupportedImage(ProviderImageInfo file)
{
return true;
}
Expand Down
1 change: 1 addition & 0 deletions ComicRack/Changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Community Edition Build 0.9.180:
* NEW: Added the Web field to smart list, so no more need to use expressions. (Again backup your DB, this could result in a corrupted database if going back to an older version)
* NEW: Added an "Is Missing" smart list entry. (Again backup your DB, this could result in a corrupted database if going back to an older version)
* NEW: "__MACOSX" & ".DS_Store" folders will be ignored inside archives.
* NEW: Images smaller than 512 bytes will be ignored inside archives.

* CHANGE: Updated to .NET Framework v4.8.
* CHANGE: Updated the Splash Screen and Renamed the Program to Community Edition, this means that a new config folder will be used %appdata%\cYo\ComicRack Community Edition.
Expand Down

0 comments on commit ff00007

Please sign in to comment.