Skip to content

Commit

Permalink
using md5_file() in contents reader
Browse files Browse the repository at this point in the history
  • Loading branch information
naneau committed Sep 15, 2014
1 parent 10833f8 commit ff466a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
16 changes: 7 additions & 9 deletions src/Naneau/ProjectVersioner/Reader/Finder/Contents.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,18 @@ class Contents extends Finder
**/
public function read($directory)
{
$contents = '';
$hash = '';
foreach ($this->getFinder() as $file) {
var_dump($file);

$fileContents = file_get_contents(
$file->getPath()
. DIRECTORY_SEPARATOR . $file->getFilename()
// MD5 hash of the file
$fileHash = md5_file(
$file->getPath() . DIRECTORY_SEPARATOR . $file->getFilename()
);

var_dump($contents, $fileContents);

$contents = md5($contents . $fileContents);
// Mix into result hash
$hash = md5($hash . $fileHash);
}

return substr($contents, 0, 6);
return substr($hash, 0, 6);
}
}
3 changes: 1 addition & 2 deletions tests/Reader/FinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ public function testContents()
{
$versioner = new Versioner(array(new ContentsReader('*.php')));

$hash = 'ee53e4';
$this->assertEquals(
$hash,
'db9d80',
$versioner->get(
__DIR__ . '/../projects/finder'
)
Expand Down

0 comments on commit ff466a0

Please sign in to comment.