mirror of https://github.com/zlatinb/muwire
explicitly use longs
parent
858c223b4c
commit
82cc664fa2
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue