You are here

protected function DrupalEncrypt::_encryptFile in Backup and Migrate 5.0.x

1 call to DrupalEncrypt::_encryptFile()
DrupalEncrypt::afterBackup in src/Drupal/Filter/DrupalEncrypt.php

File

src/Drupal/Filter/DrupalEncrypt.php, line 73

Class

DrupalEncrypt
@package Drupal\backup_migrate\Drupal\Filter

Namespace

Drupal\backup_migrate\Drupal\Filter

Code

protected function _encryptFile(BackupFileReadableInterface $from, BackupFileWritableInterface $to) {
  $path = \Drupal::service('file_system')
    ->realpath($from
    ->realpath());
  $out_path = \Drupal::service('file_system')
    ->realpath($to
    ->realpath());
  try {
    CryptoFile::encryptFileWithPassword($path, $out_path, $this
      ->confGet('encrypt_password'));
    $fileszc = filesize(\Drupal::service('file_system')
      ->realpath($to
      ->realpath()));
    $to
      ->setMeta('filesize', $fileszc);
    return TRUE;
  } catch (Exception $e) {
    return FALSE;
  }
}