Skip to content

Commit

Permalink
VACMS-2347 Do not tar files on cms export during deploy (#2568)
Browse files Browse the repository at this point in the history
* PHPCS fix

* Fix issue with export update

* Use correct method to find directory
  • Loading branch information
Neil Hastings authored Aug 6, 2020
1 parent 112273d commit 8916b8e
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __construct(Zippy $zippy, FileSystemInterface $fileSystem, Conta
*/
public function archive(ArchiveArgs $archiveArgs) : ArchiveInterface {
// @TODO Add locking/queueing/waiting so only one archive is occurring at a time.
$output_dir = dirname($archiveArgs->getOutputPath());
$output_dir = $this->fileSystem->dirname($archiveArgs->getOutputPath());
$this->fileSystem->prepareDirectory($output_dir, FileSystemInterface::CREATE_DIRECTORY);

$input_path = $this->fileSystem->realpath($archiveArgs->getCurrentWorkingDirectory());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Drupal\va_gov_content_export\Archive\ArchiveArgs;
use Drupal\va_gov_content_export\Archive\ArchiveArgsFactory;
use Drupal\va_gov_content_export\Archive\ArchiveDirectory;
use Drupal\va_gov_content_export\SiteStatus\SiteStatusInterface;
use Exception;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
Expand Down Expand Up @@ -47,6 +48,13 @@ class ContentExport extends ControllerBase {
*/
public const ALLOWED_EXPORT_TYPES = ['content', 'asset'];

/**
* Site Status.
*
* @var \Drupal\va_gov_content_export\SiteStatus\SiteStatusInterface
*/
private $siteStatus;

/**
* ContentExport constructor.
*
Expand All @@ -56,11 +64,14 @@ class ContentExport extends ControllerBase {
* Kill switch.
* @param \Drupal\va_gov_content_export\Archive\ArchiveArgsFactory $archiveArgsFactory
* The Archive Args factory.
* @param \Drupal\va_gov_content_export\SiteStatus\SiteStatusInterface $siteStatus
* The Site Status Service.
*/
public function __construct(ArchiveDirectory $archiver, KillSwitch $killSwitch, ArchiveArgsFactory $archiveArgsFactory) {
public function __construct(ArchiveDirectory $archiver, KillSwitch $killSwitch, ArchiveArgsFactory $archiveArgsFactory, SiteStatusInterface $siteStatus) {
$this->archiver = $archiver;
$this->killSwitch = $killSwitch;
$this->archiveArgsFactory = $archiveArgsFactory;
$this->siteStatus = $siteStatus;
}

/**
Expand All @@ -70,7 +81,8 @@ public static function create(ContainerInterface $container) {
return new static(
$container->get('va_gov.content_export.archive_directory'),
$container->get('page_cache_kill_switch'),
$container->get('va_gov.content_export.archive_args_factory')
$container->get('va_gov.content_export.archive_args_factory'),
$container->get('va_gov.site_status')
);
}

Expand All @@ -97,7 +109,9 @@ public function redirectToFile(string $export_type) : Response {
$this->killSwitch->trigger();
try {
$archive_args = $this->getArchiveArgs($export_type);
$this->archiver->archive($archive_args);
if (!$this->siteStatus->inDeployMode()) {
$this->archiver->archive($archive_args);
}
$file_name = $archive_args->getOutputPath();

if (!file_exists($file_name)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Drupal\va_gov_content_export\SiteStatus;

use Drupal\Core\Site\Settings;

/**
* SiteStatus Service.
*/
class SiteStatus implements SiteStatusInterface {

/**
* {@inheritDoc}
*/
public function inDeployMode(): bool {
return Settings::get('va_site_deploy_mode', FALSE);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Drupal\va_gov_content_export\SiteStatus;

/**
* Interface SiteStatusInterface.
*/
interface SiteStatusInterface {

/**
* Is the site currently in Deploy Mode.
*
* @return bool
* In Deploy Mode.
*/
public function inDeployMode() : bool;

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ services:
arguments: ['@tome_sync.exporter', '@event_dispatcher', '@va_gov.content_export.executable_finder']
va_gov.content_export.executable_finder:
class: Drupal\va_gov_content_export\ExportCommand\ExecutableFinder
va_gov.site_status:
class: Drupal\va_gov_content_export\SiteStatus\SiteStatus

1 comment on commit 8916b8e

@va-cms-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Test Failed: va/tests/accessibility
composer va:test:accessibility
> npm install --only=production
npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR! network request to https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz failed, reason: read ECONNRESET
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network 
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR!     /var/www/.npm/_logs/2020-08-06T16_45_04_716Z-debug.log
Script npm install --only=production handling the va:test:accessibility event returned with error code 1
  • On: ip-10-247-35-19
  • In: 02:24

Please sign in to comment.