You are here

protected function DiskSpace::diskSpaceCheck in Automatic Updates 8

Check if the filesystem has sufficient disk space.

Return value

array An array of translatable strings if there is not sufficient space.

1 call to DiskSpace::diskSpaceCheck()
DiskSpace::doCheck in src/ReadinessChecker/DiskSpace.php
Perform checks.

File

src/ReadinessChecker/DiskSpace.php, line 35

Class

DiskSpace
Disk space checker.

Namespace

Drupal\automatic_updates\ReadinessChecker

Code

protected function diskSpaceCheck() {
  $messages = [];
  if (!$this
    ->areSameLogicalDisk($this
    ->getRootPath(), $this
    ->getVendorPath())) {
    if (disk_free_space($this
      ->getRootPath()) < static::MINIMUM_DISK_SPACE) {
      $messages[] = $this
        ->t('Drupal root filesystem "@root" has insufficient space. There must be at least @space megabytes free.', [
        '@root' => $this
          ->getRootPath(),
        '@space' => static::MINIMUM_DISK_SPACE / static::MEGABYTE_DIVISOR,
      ]);
    }
    if (is_dir($this
      ->getVendorPath()) && disk_free_space($this
      ->getVendorPath()) < static::MINIMUM_DISK_SPACE) {
      $messages[] = $this
        ->t('Vendor filesystem "@vendor" has insufficient space. There must be at least @space megabytes free.', [
        '@vendor' => $this
          ->getVendorPath(),
        '@space' => static::MINIMUM_DISK_SPACE / static::MEGABYTE_DIVISOR,
      ]);
    }
  }
  elseif (disk_free_space($this
    ->getRootPath()) < static::MINIMUM_DISK_SPACE) {
    $messages[] = $this
      ->t('Logical disk "@root" has insufficient space. There must be at least @space megabytes free.', [
      '@root' => $this
        ->getRootPath(),
      '@space' => static::MINIMUM_DISK_SPACE / static::MEGABYTE_DIVISOR,
    ]);
  }
  $temp = FileSystemComponent::getOsTemporaryDirectory();
  if (disk_free_space($temp) < static::MINIMUM_DISK_SPACE) {
    $messages[] = $this
      ->t('Directory "@temp" has insufficient space. There must be at least @space megabytes free.', [
      '@temp' => $temp,
      '@space' => static::MINIMUM_DISK_SPACE / static::MEGABYTE_DIVISOR,
    ]);
  }
  return $messages;
}