Commit 675b1a6a authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3323446 by phenaproxima, bschwetzel: Change update 9001 so that it...

Issue #3323446 by phenaproxima, bschwetzel: Change update 9001 so that it downloads tar files instead
parent 0f250425
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 * Contains installation and update functions for Lightning Media Bulk Upload.
 */

use Drupal\Core\Archiver\Zip;
use Drupal\Core\Archiver\Tar;
use GuzzleHttp\RequestOptions;

/**
@@ -27,7 +27,7 @@ function lightning_media_bulk_upload_update_9001(array &$sandbox) {
  }

  // Allow the destination directory to be overridden in tests.
  $destination = $sandbox[__FUNCTION__] ?? Drupal::root() . '/libraries/dropzone';
  $destination = $sandbox[__FUNCTION__] ?? Drupal::root() . '/libraries';

  // Ensure the destination exists and is writable, or abort the update.
  /** @var \Drupal\Core\File\FileSystemInterface $file_system */
@@ -45,14 +45,16 @@ function lightning_media_bulk_upload_update_9001(array &$sandbox) {
  }

  Drupal::httpClient()
    ->request('GET', 'https://github.com/dropzone/dropzone/releases/download/v5.9.3/dist.zip', [
    ->request('GET', 'https://github.com/dropzone/dropzone-packagist/archive/refs/tags/v5.7.3.tar.gz', [
      RequestOptions::SINK => $file,
    ]);

  $archiver = new Zip($file);
  $archiver = new Tar($file);
  $archiver->extract($destination);
  rename("$destination/dropzone-packagist-5.7.3", "$destination/dropzone");
  $file_system->delete($file);

  $destination .= '/dropzone';
  return t('The Dropzone JavaScript library was installed in %destination. Remember to add it to your version control system.', [
    '%destination' => $destination,
  ]);
+654 B

File added.

No diff preview for this file type.

−412 B

File deleted.

+4 −4
Original line number Diff line number Diff line
@@ -38,11 +38,11 @@ class Update9001Test extends KernelTestBase {

    // Mock the HTTP client so it returns our fake zip file when downloading
    // Dropzone.
    $zip = fopen(__DIR__ . '/../../fixtures/dropzone.zip', 'rb');
    $this->assertIsResource($zip);
    $tar = fopen(__DIR__ . '/../../fixtures/dropzone.tar.gz', 'rb');
    $this->assertIsResource($tar);

    $handler = new MockHandler([
      new Response(200, ['Content-Type' => 'application/zip'], $zip),
      new Response(200, ['Content-Type' => 'application/tar+gzip'], $tar),
    ]);
    $client = new Client([
      'handler' => HandlerStack::create($handler),
@@ -50,7 +50,7 @@ class Update9001Test extends KernelTestBase {
    $this->container->set('http_client', $client);

    $sandbox = [
      'lightning_media_bulk_upload_update_9001' => 'public://libraries/dropzone',
      'lightning_media_bulk_upload_update_9001' => 'public://libraries',
    ];
    $this->container->get('module_handler')
      ->loadInclude('lightning_media_bulk_upload', 'install');
+3 −3
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 * Contains install and update routines for Lightning Media Image.
 */

use Drupal\Core\Archiver\Zip;
use Drupal\Core\Archiver\Tar;
use Drupal\lightning_core\ConfigHelper as Config;
use GuzzleHttp\RequestOptions;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
@@ -184,11 +184,11 @@ function lightning_media_image_update_9001(array &$sandbox) {
  }

  Drupal::httpClient()
    ->request('GET', 'https://github.com/fengyuanchen/cropper/archive/refs/tags/v2.3.4.zip', [
    ->request('GET', 'https://github.com/fengyuanchen/cropper/archive/refs/tags/v2.3.4.tar.gz', [
      RequestOptions::SINK => $file,
    ]);

  $archiver = new Zip($file);
  $archiver = new Tar($file);
  $archiver->extract($destination);
  rename("$destination/cropper-2.3.4", "$destination/cropper");
  $file_system->delete($file);
Loading