You are here

function drush_s3fs_copy_local in S3 File System 8.2

Same name and namespace in other branches
  1. 7.3 s3fs.drush.inc \drush_s3fs_copy_local()
  2. 7.2 s3fs.drush.inc \drush_s3fs_copy_local()

Implements drush_hook_COMMAND().

Copies all files from the local public/private filesystem folders into S3, if s3fs is configured to take over those systems.

1 string reference to 'drush_s3fs_copy_local'
s3fs_drush_command in ./s3fs.drush.inc
Implements hook_drush_command().

File

./s3fs.drush.inc, line 34
Defines a drush command that refreshes the S3 metadata cache.

Code

function drush_s3fs_copy_local() {
  $config = \Drupal::config('s3fs.settings')
    ->get();
  if (!\Drupal::service('s3fs.validate')
    ->validate($config)) {
    drupal_set_message(t('Unable to validate your s3fs configuration settings. Please configure S3 File System from the admin/config/media/s3fs page and try again.'), 'error');
    return;
  }
  if (empty(Settings::get('s3fs.use_s3_for_public')) && empty(Settings::get('s3fs.use_s3_for_private'))) {
    drupal_set_message(t('S3 File System is not configured to take over any other file systems.'));
    return;
  }
  if (!empty(Settings::get('s3fs.use_s3_for_public'))) {
    \Drupal::service('s3fs.validate')
      ->copyFileSystemToS3($config, 'public');
  }
  if (!empty(Settings::get('s3fs.use_s3_for_public'))) {
    \Drupal::service('s3fs.validate')
      ->copyFileSystemToS3($config, 'private');
  }
}