private function loadSourceHash(PhutilSprite $sprite) { $inputs = array(); foreach ($this->scales as $scale) { $file = $sprite->getSourceFile($scale); // If two users have a project in different places, like: // // /home/alincoln/project // /home/htaft/project // // ...we want to ignore the `/home/alincoln` part when hashing the sheet, // since the sprites don't change when the project directory moves. If // the base path is set, build the hashes using paths relative to the // base path. $file_key = $file; if ($this->basePath) { $file_key = Filesystem::readablePath($file, $this->basePath); } if (empty($this->hashes[$file_key])) { $this->hashes[$file_key] = md5(Filesystem::readFile($file)); } $inputs[] = $file_key; $inputs[] = $this->hashes[$file_key]; } $inputs[] = $sprite->getSourceX(); $inputs[] = $sprite->getSourceY(); $inputs[] = $sprite->getSourceW(); $inputs[] = $sprite->getSourceH(); return md5(implode(':', $inputs)); }
private function loadSourceHash(PhutilSprite $sprite) { $inputs = array(); foreach ($this->scales as $scale) { $file = $sprite->getSourceFile($scale); if (empty($this->hashes[$file])) { $this->hashes[$file] = md5(Filesystem::readFile($file)); } $inputs[] = $file; $inputs[] = $this->hashes[$file]; } $inputs[] = $sprite->getSourceX(); $inputs[] = $sprite->getSourceY(); $inputs[] = $sprite->getSourceW(); $inputs[] = $sprite->getSourceH(); return md5(implode(':', $inputs)); }