Skip to content

Commit

Permalink
Tweak purge script
Browse files Browse the repository at this point in the history
  • Loading branch information
g105b committed Oct 31, 2014
1 parent bef4344 commit 7f5a839
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/ClientSide/FileOrganiser.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ public function purgeStaticWwwFiles() {
foreach(new \DirectoryIterator(Path::get(Path::WWW)) as $item) {
$filename = $item->getFilename();


if($filename === $assetDirName
|| strpos($filename, $scriptDirName) . "-" === 0
|| strpos($filename, $styleDirName) . "-" === 0) {
|| strpos($filename, $scriptDirName . "-") === 0
|| strpos($filename, $styleDirName . "-") === 0) {
DirectoryRecursor::purge($item->getPathname());
}
}
Expand Down Expand Up @@ -189,13 +190,13 @@ public function checkStaticValid() {
// Recursive fingerprint whole source directory.
$staticWwwFingerprint = file_get_contents($this->staticFingerprintFile);

$assetSrcFingerprint = $this->recursiveFingerprint([
$staticSrcFingerprint = $this->recursiveFingerprint([
$assetSrcDir,
$scriptSrcDir,
$styleSrcDir,
]);

return ($staticWwwFingerprint === $assetSrcFingerprint);
return ($staticWwwFingerprint === $staticSrcFingerprint);
}

/**
Expand Down Expand Up @@ -297,7 +298,7 @@ private function recursiveFingerprint($dir) {
return $this->emptyHash;
}

return $hash;
return md5($hash);
}

}#
3 changes: 2 additions & 1 deletion src/Core/DirectoryRecursor.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ private static function hashFile($file, $iterator) {
public static function purge($path) {
$count = 0;

self::walk($path, ["self::purgeFile"], $count,
self::walk($path, "self::purgeFile", $count,
\RecursiveIteratorIterator::CHILD_FIRST);
rmdir($path);

return $count;
}
Expand Down
4 changes: 4 additions & 0 deletions test/Unit/ClientSide/FileOrganiser.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ public function testAssetDoesNotCopyIfNoSourceDirectory() {
"shouldn't copy any files if no source directory present");
}

public function testStaticSourceFileEditInvalidates() {
// TODO.
}

public function testOrganiseFunctionCopiesAssets() {
$dir = $this->getPath(Path::ASSET);
$fileArray = [
Expand Down

0 comments on commit 7f5a839

Please sign in to comment.