/** * @return array */ protected function getHashes() { $hashes = array(); list($oldRels, $deleteCurrent) = $this->getOldRels(); if ($deleteCurrent) { $hashes['.'] = $this->file->getSha1(); } if (count($oldRels)) { $dbw = $this->file->repo->getMasterDB(); $res = $dbw->select('oldimage', array('oi_archive_name', 'oi_sha1'), array('oi_archive_name' => array_keys($oldRels)), __METHOD__); foreach ($res as $row) { if (rtrim($row->oi_sha1, "") === '') { // Get the hash from the file $oldUrl = $this->file->getArchiveVirtualUrl($row->oi_archive_name); $props = $this->file->repo->getFileProps($oldUrl); if ($props['fileExists']) { // Upgrade the oldimage row $dbw->update('oldimage', array('oi_sha1' => $props['sha1']), array('oi_name' => $this->file->getName(), 'oi_archive_name' => $row->oi_archive_name), __METHOD__); $hashes[$row->oi_archive_name] = $props['sha1']; } else { $hashes[$row->oi_archive_name] = false; } } else { $hashes[$row->oi_archive_name] = $row->oi_sha1; } } } $missing = array_diff_key($this->srcRels, $hashes); foreach ($missing as $name => $rel) { $this->status->error('filedelete-old-unregistered', $name); } foreach ($hashes as $name => $hash) { if (!$hash) { $this->status->error('filedelete-missing', $this->srcRels[$name]); unset($hashes[$name]); } } return $hashes; }