/** * remove custom mtime metadata * @param \CF_Object $obj */ private function resetMTime($obj) { if (isset($obj->metadata['Mtime'])) { $obj->metadata['Mtime'] = -1; $obj->sync_metadata(); } }
/** * Fill in any missing object metadata and save it to Swift * * @param $obj CF_Object * @param $path string Storage path to object * @return bool Success * @throws Exception cloudfiles exceptions */ protected function addMissingMetadata(CF_Object $obj, $path) { if (isset($obj->metadata['Sha1base36'])) { return true; // nothing to do } wfProfileIn(__METHOD__); $status = Status::newGood(); $scopeLockS = $this->getScopedFileLocks(array($path), LockManager::LOCK_UW, $status); if ($status->isOK()) { # Do not stat the file in getLocalCopy() to avoid infinite loops $tmpFile = $this->getLocalCopy(array('src' => $path, 'latest' => 1, 'nostat' => 1)); if ($tmpFile) { $hash = $tmpFile->getSha1Base36(); if ($hash !== false) { $obj->metadata['Sha1base36'] = $hash; $obj->sync_metadata(); // save to Swift wfProfileOut(__METHOD__); return true; // success } } } $obj->metadata['Sha1base36'] = false; wfProfileOut(__METHOD__); return false; // failed }
/** * Fill in any missing object metadata and save it to Swift * * @param $obj CF_Object * @param string $path Storage path to object * @return bool Success * @throws Exception cloudfiles exceptions */ protected function addMissingMetadata(CF_Object $obj, $path) { if ($obj->getMetadataValue('Sha1base36') !== null) { return true; // nothing to do } wfProfileIn(__METHOD__); trigger_error("{$path} was not stored with SHA-1 metadata.", E_USER_WARNING); $status = Status::newGood(); $scopeLockS = $this->getScopedFileLocks(array($path), LockManager::LOCK_UW, $status); if ($status->isOK()) { $tmpFile = $this->getLocalCopy(array('src' => $path, 'latest' => 1)); if ($tmpFile) { $hash = $tmpFile->getSha1Base36(); if ($hash !== false) { $obj->setMetadataValues(array('Sha1base36' => $hash)); $obj->sync_metadata(); // save to Swift wfProfileOut(__METHOD__); return true; // success } } } trigger_error("Unable to set SHA-1 metadata for {$path}", E_USER_WARNING); $obj->setMetadataValues(array('Sha1base36' => false)); wfProfileOut(__METHOD__); return false; // failed }
/** * Fill in any missing object metadata and save it to Swift * * @param $obj CF_Object * @param $path string Storage path to object * @return bool Success * @throws Exception cloudfiles exceptions */ protected function addMissingMetadata(CF_Object $obj, $path) { if (isset($obj->metadata['Sha1base36'])) { return true; // nothing to do } $status = Status::newGood(); $scopeLockS = $this->getScopedFileLocks(array($path), LockManager::LOCK_UW, $status); if ($status->isOK()) { $tmpFile = $this->getLocalCopy(array('src' => $path, 'latest' => 1)); if ($tmpFile) { $hash = $tmpFile->getSha1Base36(); if ($hash !== false) { $obj->metadata['Sha1base36'] = $hash; $obj->sync_metadata(); // save to Swift return true; // success } } } $obj->metadata['Sha1base36'] = false; return false; // failed }