[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [snapshot/master] Use SHA1.file().hexdigest, because ruby calculates the SHA1 wrong on large input otherwise (#668294)



Hi Peter,

does it mean that anything needs to be done on already existing entries?
and does "large" has any concrete number here? ;)

On Tue, 10 Apr 2012, Peter Palfrader wrote:

> ---
>  snapshot |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

> diff --git a/snapshot b/snapshot
> index 9bd330b..6548fb6 100755
> --- a/snapshot
> +++ b/snapshot
> @@ -454,7 +454,7 @@ class FSNodeRegular < FSNodeRegularBase
>  			end
>  		end
>  		if get_digest
> -			digest = Digest::SHA1.hexdigest( File.open(@truepath).read )
> +			digest = Digest::SHA1.file(@truepath).hexdigest
>  		end

>  		super(path, parent, statinfo.size, digest)
> @@ -462,7 +462,7 @@ class FSNodeRegular < FSNodeRegularBase

>  	def get_digest
>  		return @digest if @digest
> -		@digest = Digest::SHA1.hexdigest( File.open(@truepath).read )
> +		@digest = Digest::SHA1.file(@truepath).hexdigest
>  		@digest
>  	end
-- 
Yaroslav O. Halchenko
Postdoctoral Fellow,   Department of Psychological and Brain Sciences
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834                       Fax: +1 (603) 646-1419
WWW:   http://www.linkedin.com/in/yarik        


Reply to: