From b395fce5370a9dc020478c5461b230cbc097e092 Mon Sep 17 00:00:00 2001 From: Fran Garcia-Linares <fjgarlin@gmail.com> Date: Thu, 20 Jun 2024 12:11:19 +0200 Subject: [PATCH] Issue #3455915: Try local file first, otherwise remote. --- drupalorg_migrate.module | 3 ++ .../drupalorg_migrate_project_files.yml | 30 +++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/drupalorg_migrate.module b/drupalorg_migrate.module index af933ab..b09c46f 100644 --- a/drupalorg_migrate.module +++ b/drupalorg_migrate.module @@ -20,6 +20,9 @@ function drupalorg_migrate_migration_plugins_alter(array &$migrations) { if (!empty($paths['source'])) { $migrations[$id]['source']['constants']['source_base_path'] = $paths['source']; } + if (!empty($paths['remote'])) { + $migrations[$id]['remote']['constants']['remote_base_path'] = $paths['remote']; + } } } } diff --git a/migrations/drupalorg_migrate_project_files.yml b/migrations/drupalorg_migrate_project_files.yml index 6485895..2c37211 100644 --- a/migrations/drupalorg_migrate_project_files.yml +++ b/migrations/drupalorg_migrate_project_files.yml @@ -15,7 +15,8 @@ source: constants: # Path changed via hook_migration_plugins_alter # and set via $config['drupalorg_migrate']['project_files']['source'] - source_base_path: 'https://www.drupal.org' + source_base_path: '/var/www/html/web/files/d7-files' + remote_base_path: 'https://www.drupal.org' destination: plugin: entity:file @@ -25,15 +26,38 @@ process: # the fid field to allow incremental migrations. # fid: fid filename: filename - source_full_path: + local_temp_path: + plugin: concat + delimiter: / + source: + - constants/source_base_path + - filepath + local_full_path: + - + plugin: callback + callable: file_exists + source: '@local_temp_path' + - + plugin: skip_on_empty + method: process + - + plugin: get + source: '@local_temp_path' + remote_full_path: - plugin: concat delimiter: / source: - - constants/source_base_path + - constants/remote_base_path - filepath - plugin: urlencode + source_full_path: + - + plugin: null_coalesce + source: + - '@local_full_path' + - '@remote_full_path' uri: plugin: file_copy source: -- GitLab