Airship\Engine\Continuum\Updaters\Gadget::install PHP Method

install() protected method

If we get to this point: 1. We know the signature is signed by the supplier. 2. The hash was checked into Keyggdrasil, which was independently vouched for by our peers.
protected install ( UpdateInfo $info, UpdateFile $file )
$info UpdateInfo
$file UpdateFile
    protected function install(UpdateInfo $info, UpdateFile $file)
    {
        if (!$file->hashMatches($info->getChecksum())) {
            throw new CouldNotUpdate(\__('Checksum mismatched'));
        }
        // Create a backup of the old Gadget:
        \rename($this->filePath, $this->filePath . '.backup');
        \rename($file->getPath(), $this->filePath);
        $this->log('Begin install process', LogLevel::DEBUG, ['path' => $file->getPath(), 'hash' => $file->getHash(), 'version' => $file->getVersion(), 'size' => $file->getSize()]);
        // Get metadata from the old version of this Gadget:
        $oldAlias = Base64UrlSafe::encode(\random_bytes(48)) . '.phar';
        $oldGadget = new \Phar($this->filePath, \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::KEY_AS_FILENAME);
        $oldGadget->setAlias($oldAlias);
        $oldMetadata = $oldGadget->getMetadata();
        unset($oldGadget);
        unset($oldAlias);
        // Let's open the update package:
        $newGadget = new \Phar($this->filePath, \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::KEY_AS_FILENAME, $this->pharAlias);
        $newGadget->setAlias($this->pharAlias);
        $metaData = $newGadget->getMetadata();
        // We need to do this while we're replacing files.
        $this->bringSiteDown();
        Sandbox::safeRequire('phar://' . $this->pharAlias . '/update_trigger.php', $oldMetadata);
        // Free up the updater alias
        $garbageAlias = Base64UrlSafe::encode(\random_bytes(48)) . '.phar';
        $newGadget->setAlias($garbageAlias);
        unset($newGadget);
        // Now bring it back up.
        $this->bringSiteBackUp();
        // Make sure we update the version info. in the DB cache:
        $this->updateDBRecord('Gadget', $info);
        if ($metaData) {
            $this->updateJSON($info, $metaData);
        }
        self::$continuumLogger->store(LogLevel::INFO, 'Gadget update installed', $this->getLogContext($info, $file));
    }