Ejemplo n.º 1
0
 /**
  * Roll back the DB transaction and mark the image unlocked
  */
 function unlockAndRollback()
 {
     $this->locked = false;
     $dbw = $this->repo->getMasterDB();
     $dbw->rollback(__METHOD__);
     $this->lockedOwnTrx = false;
 }
Ejemplo n.º 2
0
 /**
  * Get the chunk db state and populate update relevant local values
  */
 private function getChunkStatus()
 {
     // get Master db to avoid race conditions.
     // Otherwise, if chunk upload time < replag there will be spurious errors
     $dbw = $this->repo->getMasterDB();
     $row = $dbw->selectRow('uploadstash', ['us_chunk_inx', 'us_size', 'us_path'], ['us_key' => $this->mFileKey], __METHOD__);
     // Handle result:
     if ($row) {
         $this->mChunkIndex = $row->us_chunk_inx;
         $this->mOffset = $row->us_size;
         $this->mVirtualTempPath = $row->us_path;
     }
 }
Ejemplo n.º 3
0
 /**
  * Helper function: do the actual database query to fetch file metadata.
  *
  * @param string $key
  * @param int $readFromDB Constant (default: DB_REPLICA)
  * @return bool
  */
 protected function fetchFileMetadata($key, $readFromDB = DB_REPLICA)
 {
     // populate $fileMetadata[$key]
     $dbr = null;
     if ($readFromDB === DB_MASTER) {
         // sometimes reading from the master is necessary, if there's replication lag.
         $dbr = $this->repo->getMasterDB();
     } else {
         $dbr = $this->repo->getSlaveDB();
     }
     $row = $dbr->selectRow('uploadstash', '*', ['us_key' => $key], __METHOD__);
     if (!is_object($row)) {
         // key wasn't present in the database. this will happen sometimes.
         return false;
     }
     $this->fileMetadata[$key] = (array) $row;
     $this->fileMetadata[$key]['us_props'] = $dbr->decodeBlob($row->us_props);
     return true;
 }