public function tearDown()
 {
     if (file_exists(__DIR__ . '/_files/output/pack')) {
         $helper = new \Magento\Framework\Backup\Filesystem\Helper();
         $helper->rm(__DIR__ . '/_files/output/pack', [], true);
     }
 }
Exemplo n.º 2
0
 private function removeCsv($module)
 {
     if (file_exists(__DIR__ . "/_files/root/app/code/Magento/{$module}/i18n")) {
         $helper = new \Magento\Framework\Backup\Filesystem\Helper();
         $helper->rm(__DIR__ . "/_files/root/app/code/Magento/{$module}/i18n", [], true);
     }
 }
Exemplo n.º 3
0
 /**
  * Files rollback implementation via ftp
  *
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  *
  * @see AbstractRollback::run()
  */
 public function run()
 {
     $snapshotPath = $this->_snapshot->getBackupPath();
     if (!is_file($snapshotPath) || !is_readable($snapshotPath)) {
         throw new \Magento\Framework\Backup\Exception\CantLoadSnapshot(new \Magento\Framework\Phrase('Can\'t load snapshot archive'));
     }
     $this->_initFtpClient();
     $this->_validateFtp();
     $tmpDir = $this->_createTmpDir();
     $this->_unpackSnapshot($tmpDir);
     $fsHelper = new \Magento\Framework\Backup\Filesystem\Helper();
     $this->_cleanupFtp();
     $this->_uploadBackupToFtp($tmpDir);
     $fsHelper->rm($tmpDir, [], true);
 }
Exemplo n.º 4
0
 /**
  * Files rollback implementation via local filesystem
  *
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  *
  * @see AbstractRollback::run()
  */
 public function run()
 {
     $snapshotPath = $this->_snapshot->getBackupPath();
     if (!is_file($snapshotPath) || !is_readable($snapshotPath)) {
         throw new \Magento\Framework\Backup\Exception\CantLoadSnapshot(new \Magento\Framework\Phrase('Can\'t load snapshot archive'));
     }
     $fsHelper = new \Magento\Framework\Backup\Filesystem\Helper();
     $filesInfo = $fsHelper->getInfo($this->_snapshot->getRootDir(), \Magento\Framework\Backup\Filesystem\Helper::INFO_WRITABLE, $this->_snapshot->getIgnorePaths());
     if (!$filesInfo['writable']) {
         throw new \Magento\Framework\Backup\Exception\NotEnoughPermissions(new \Magento\Framework\Phrase('Unable to make rollback because not all files are writable'));
     }
     $archiver = new \Magento\Framework\Archive();
     /**
      * we need these fake initializations because all magento's files in filesystem will be deleted and autoloader
      * wont be able to load classes that we need for unpacking
      */
     new \Magento\Framework\Archive\Tar();
     new \Magento\Framework\Archive\Gz();
     new \Magento\Framework\Archive\Helper\File('');
     new \Magento\Framework\Archive\Helper\File\Gz('');
     $fsHelper->rm($this->_snapshot->getRootDir(), $this->_snapshot->getIgnorePaths());
     $archiver->unpack($snapshotPath, $this->_snapshot->getRootDir());
 }