/** * @return array|null */ public function getDuplicates() { $this->loadFile(); if (!is_null($this->mDupes)) { return $this->mDupes; } $hash = $this->mFile->getSha1(); if (!$hash) { $this->mDupes = []; return $this->mDupes; } $dupes = RepoGroup::singleton()->findBySha1($hash); // Remove duplicates with self and non matching file sizes $self = $this->mFile->getRepoName() . ':' . $this->mFile->getName(); $size = $this->mFile->getSize(); /** * @var $file File */ foreach ($dupes as $index => $file) { $key = $file->getRepoName() . ':' . $file->getName(); if ($key == $self) { unset($dupes[$index]); } if ($file->getSize() != $size) { unset($dupes[$index]); } } $this->mDupes = $dupes; return $this->mDupes; }