trueai-org / mdrive

一个基于阿里云盘官方 API 授权的自动同步和备份工具,支持云盘挂载到本地,支持本地存储,支持加密,多平台、安全、自动化的数据管理方案。
https://duplicati.net
Apache License 2.0
153 stars 26 forks source link

加载文件目录下标异常 #26

Open healzy99 opened 3 months ago

healzy99 commented 3 months ago

加载本地目录文件异常 D:\download\upload\ System.ArgumentOutOfRangeException: 'minValue' cannot be greater than maxValue. (Parameter 'minValue') at System.Random.ThrowMinMaxValueSwapped() at System.Random.Next(Int32 minValue, Int32 maxValue) at MDriveSync.Core.ShaHashHelper.GetSamplePoints(Int64 fileLength, Int32 sampleSize, Int32 numberOfRandomSamples, Int32 seed) at MDriveSync.Core.ShaHashHelper.ComputeFileSampleHashHex(String filePath, String algorithm, Int32 seed) at MDriveSync.Core.ShaHashHelper.ComputeFileSampleHash(String filePath, String alg, Int32 seed) at MDriveSync.Core.ShaHashHelper.ComputeFileHash(String filePath, Int32 level, String alg, Int64 seed) at MDriveSync.Core.AliyunJob.<>c__DisplayClass65_1.g__LoadFiles|4(String dir)

Zrincet commented 1 month ago

https://github.com/trueai-org/mdrive/blob/70b240b13360d6c300b4418acdaefca5a3ae30ab/src/MDriveSync.Core/Services/ShaHashHelper.cs#L54-L57

如果不满足fileLength <= sampleSize * (3 + numberOfRandomSamples)sampleSize 大于fileLength 时,

https://github.com/trueai-org/mdrive/blob/70b240b13360d6c300b4418acdaefca5a3ae30ab/src/MDriveSync.Core/Services/ShaHashHelper.cs#L99

random.Next 可能出现minValue大于maxValue的情况, @trueai-org 大佬看看是不是需要修改一下临界条件