diff --git a/core/src/main/groovy/com/muwire/core/FileHasher.groovy b/core/src/main/groovy/com/muwire/core/FileHasher.groovy index 18ce2503..cd952cd3 100644 --- a/core/src/main/groovy/com/muwire/core/FileHasher.groovy +++ b/core/src/main/groovy/com/muwire/core/FileHasher.groovy @@ -3,7 +3,7 @@ package com.muwire.core class FileHasher { /** max size of shared file is 128 GB */ - public static final long MAX_SIZE = 0x1 << 37 + public static final long MAX_SIZE = 0x1L << 37 /** * @param size of the file to be shared @@ -14,7 +14,7 @@ class FileHasher { return 18 for (int i = 26; i <= 37; i++) { - if (size <= 0x1 << i) { + if (size <= 0x1L << i) { return i-7 } } diff --git a/core/src/test/groovy/com/muwire/core/FileHasherTest.groovy b/core/src/test/groovy/com/muwire/core/FileHasherTest.groovy index 61cc2409..3c3512b9 100644 --- a/core/src/test/groovy/com/muwire/core/FileHasherTest.groovy +++ b/core/src/test/groovy/com/muwire/core/FileHasherTest.groovy @@ -10,6 +10,7 @@ class FileHasherTest extends GroovyTestCase { void testPieceSize() { assert 18 == FileHasher.getPieceSize(1000000) assert 20 == FileHasher.getPieceSize(100000000) + assert 30 == FileHasher.getPieceSize(FileHasher.MAX_SIZE) shouldFail IllegalArgumentException, { FileHasher.getPieceSize(Long.MAX_VALUE) }