Merge pull request #7824 from owncloud/hash-parameter-order
Fix parameter order for Storage\Local::hash
This commit is contained in:
commit
70db348475
|
@ -160,8 +160,7 @@ abstract class Common implements \OC\Files\Storage\Storage {
|
||||||
|
|
||||||
public function hash($type, $path, $raw = false) {
|
public function hash($type, $path, $raw = false) {
|
||||||
$tmpFile = $this->getLocalFile($path);
|
$tmpFile = $this->getLocalFile($path);
|
||||||
$hash = hash($type, $tmpFile, $raw);
|
$hash = hash_file($type, $tmpFile, $raw);
|
||||||
unlink($tmpFile);
|
|
||||||
return $hash;
|
return $hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -256,7 +256,7 @@ if (\OC_Util::runningOnWindows()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hash($path, $type, $raw = false) {
|
public function hash($type, $path, $raw = false) {
|
||||||
return hash_file($type, $this->datadir . $path, $raw);
|
return hash_file($type, $this->datadir . $path, $raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -276,7 +276,7 @@ class MappedLocal extends \OC\Files\Storage\Common{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hash($path, $type, $raw=false) {
|
public function hash($type, $path, $raw=false) {
|
||||||
return hash_file($type, $this->buildPath($path), $raw);
|
return hash_file($type, $this->buildPath($path), $raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,8 +103,7 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
|
||||||
$this->assertEquals(array(), $content);
|
$this->assertEquals(array(), $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function directoryProvider()
|
public function directoryProvider() {
|
||||||
{
|
|
||||||
return array(
|
return array(
|
||||||
array('folder'),
|
array('folder'),
|
||||||
array(' folder'),
|
array(' folder'),
|
||||||
|
@ -113,6 +112,7 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
|
||||||
array('spéciäl földer'),
|
array('spéciäl földer'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test the various uses of file_get_contents and file_put_contents
|
* test the various uses of file_get_contents and file_put_contents
|
||||||
*/
|
*/
|
||||||
|
@ -298,4 +298,21 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
|
||||||
$this->assertFalse($this->instance->file_exists('folder/bar'));
|
$this->assertFalse($this->instance->file_exists('folder/bar'));
|
||||||
$this->assertFalse($this->instance->file_exists('folder'));
|
$this->assertFalse($this->instance->file_exists('folder'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hashProvider(){
|
||||||
|
return array(
|
||||||
|
array('Foobar', 'md5'),
|
||||||
|
array('Foobar', 'sha1'),
|
||||||
|
array('Foobar', 'sha256'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider hashProvider
|
||||||
|
*/
|
||||||
|
public function testHash($data, $type) {
|
||||||
|
$this->instance->file_put_contents('hash.txt', $data);
|
||||||
|
$this->assertEquals(hash($type, $data), $this->instance->hash($type, 'hash.txt'));
|
||||||
|
$this->assertEquals(hash($type, $data, true), $this->instance->hash($type, 'hash.txt', true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue