mirror of
https://github.com/n00mkrad/flowframes.git
synced 2026-02-24 12:12:36 +01:00
Don't hash framecount of >256mb files as it's too slow and I/O heavy
This commit is contained in:
@@ -38,7 +38,7 @@ namespace Flowframes
|
||||
try { return int.Parse(str.TrimNumbers()); }
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log("Failed to parse \"" + str + "\" to int: " + e, true);
|
||||
Logger.Log("Failed to parse \"" + str + "\" to int: " + e.Message, true);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -738,13 +738,27 @@ namespace Flowframes.IO
|
||||
|
||||
public static long GetFilesize(string path)
|
||||
{
|
||||
return new FileInfo(path).Length;
|
||||
try
|
||||
{
|
||||
return new FileInfo(path).Length;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetFilesizeStr (string path)
|
||||
{
|
||||
return FormatUtils.Bytes(GetFilesize(path));
|
||||
}
|
||||
try
|
||||
{
|
||||
return FormatUtils.Bytes(GetFilesize(path));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] GetLastBytes (string path, int startAt, int bytesAmount)
|
||||
{
|
||||
|
||||
@@ -155,7 +155,9 @@ namespace Flowframes.Main
|
||||
{
|
||||
if (img == null)
|
||||
return;
|
||||
|
||||
preview.Image = img;
|
||||
|
||||
if (bigPreviewForm != null)
|
||||
bigPreviewForm.SetImage(img);
|
||||
}
|
||||
@@ -163,7 +165,13 @@ namespace Flowframes.Main
|
||||
public static Dictionary<string, int> frameCountCache = new Dictionary<string, int>();
|
||||
public static async Task<int> GetInputFrameCountAsync (string path)
|
||||
{
|
||||
string hash = await IOUtils.GetHashAsync(path, IOUtils.Hash.xxHash); // Get checksum for caching
|
||||
int maxMb = Config.GetInt("storeHashedFramecountMaxSizeMb", 256);
|
||||
string hash = "";
|
||||
|
||||
if (IOUtils.GetFilesize(path) >= 0 && IOUtils.GetFilesize(path) < maxMb * 1024 * 1024)
|
||||
hash = await IOUtils.GetHashAsync(path, IOUtils.Hash.xxHash); // Get checksum for caching
|
||||
else
|
||||
Logger.Log($"GetInputFrameCountAsync: File bigger than {maxMb}mb, won't hash.", true);
|
||||
|
||||
if (hash.Length > 1 && frameCountCache.ContainsKey(hash))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user