Example #1
0
 /**
  * {@inheritdoc}
  */
 public function loadFileMetadata(BackupFileInterface $file)
 {
     // If this file is already loaded, simply return it.
     // @TODO: fix this inappropriate use of file metadata
     if (!$file->getMeta('metadata_loaded')) {
         $metadata = $this->_loadFileMetadataArray($file);
         $file->setMetaMultiple($metadata);
         $file->setMeta('metadata_loaded', TRUE);
     }
     return $file;
 }
 /**
  * {@inheritdoc}
  */
 protected function _saveFileMetadata(BackupFileInterface $file)
 {
     // Get the file metadata and convert to INI format
     $meta = $file->getMetaAll();
     $ini = $this->_arrayToINI($meta);
     // Create an info file
     $meta_file = $this->getTempFileManager()->pushExt($file, 'info');
     $meta_file->write($ini);
     // Save the metadata
     $this->_saveFile($meta_file);
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function loadFileForReading(BackupFileInterface $file)
 {
     // If this file is already readable, simply return it.
     if ($file instanceof BackupFileReadableInterface) {
         return $file;
     }
     $id = $file->getMeta('id');
     if ($this->fileExists($id)) {
         return new ReadableStreamBackupFile($this->_idToPath($id));
     }
     return NULL;
 }
Example #4
0
 /**
  * Return a new file based on the one passed in but with the last part of the
  * file extension removed.
  * For example: xxx.mysql.gz would become xxx.mysql
  *
  *
  * @param \BackupMigrate\Core\File\BackupFileInterface $file
  * @return \BackupMigrate\Core\File\BackupFileWritableInterface
  *        A new writable backup file with the last extension removed and
  *        all of the metadata from the previous file.
  */
 public function popExt(BackupFileInterface $file)
 {
     // Pop the last extension from the last of the file.
     $parts = $file->getExtList();
     array_pop($parts);
     $new_ext = implode($parts, '.');
     // Create a new temp file with the new extension
     $out = new WritableStreamBackupFile($this->adapter->createTempFile($new_ext));
     // Copy the file metadata to a new TempFile
     $out->setMetaMultiple($file->getMetaAll());
     $out->setName($file->getName());
     $out->setExtList($parts);
     return $out;
 }