\Drupal\strata\Archive ArchiveImporter

Loads an archive into this site's store.

Content-addressed objects are verified before they are written. A frame, a commit and an anchor are all filed under the digest of their own bytes, so an archive that was edited or truncated can be caught here rather than at the moment someone needs a restore. A key whose bytes do not hash to it is refused and recorded; the rest of the archive still imports.

An import never advances the ref. The archive's own head is reported and left alone: a site importing history from elsewhere is inspecting or merging it, and silently repointing the live ref at a foreign commit would change what the site restores to without anyone asking for it.

The local indexes are not rebuilt here either. strata:reindex does that, from the objects an import has just put in place, and it is the same pass an uninstall-and-reinstall runs.

Summary

Methods
Properties
Constants
__construct
inspect
import
No public properties found
No public constants found
No protected methods found
No protected properties found
No protected constants found
reject
addressIn
open
manifest
provider
logger
No private constants found

Properties

$logger

$logger : \Psr\Log\LoggerInterface

Type

LoggerInterface

Methods

__construct()

__construct(\Drupal\strata\Storage\StorageProviderInterface  $provider, \Psr\Log\LoggerInterface  $logger) : mixed

Constructs an importer.

Parameters

\Drupal\strata\Storage\StorageProviderInterface $provider

Where objects are written.

\Psr\Log\LoggerInterface $logger

Records what was refused.

Returns

mixed —

inspect()

inspect(string  $path) : \Drupal\strata\Archive\ArchiveManifest

Reads an archive's manifest without writing anything.

Parameters

string $path

The archive.

Throws

\RuntimeException

When the file is not readable, is not an archive, or carries no manifest.

Returns

\Drupal\strata\Archive\ArchiveManifest —

What the archive says it holds.

import()

import(string  $path, bool  $apply = false) : \Drupal\strata\Archive\ArchiveManifest

Writes an archive's objects into the store.

Parameters

string $path

The archive.

bool $apply

FALSE to report what would be written without writing it.

Throws

\RuntimeException

When the file is not readable, is not an archive, or carries no manifest.

Returns

\Drupal\strata\Archive\ArchiveManifest —

What was written, with anything refused listed as a problem.

reject()

reject(string  $key, string  $body) : string|null

Why an object may not be written, if there is a reason.

Only content-addressed keys can be checked. A ref, a segment and a dictionary are named by position rather than by digest, so their bytes are taken as given - an archive is not a trust boundary, it is a transport, and a caller importing one they did not produce has already decided to trust it.

Parameters

string $key

The object key.

string $body

The bytes.

Returns

string|null —

The reason to refuse it, or NULL to write it.

addressIn()

addressIn(string  $key) : string|null

The digest a key claims its bytes hash to.

Parameters

string $key

The object key.

Returns

string|null —

The digest, or NULL when the key is not content-addressed.

open()

open(string  $path) : \Drupal\Core\Archiver\ArchiveTar

Opens an archive.

Parameters

string $path

The archive.

Throws

\RuntimeException

When the file is not readable.

Returns

\Drupal\Core\Archiver\ArchiveTar —

The open archive.

manifest()

manifest(\Drupal\Core\Archiver\ArchiveTar  $archive) : \Drupal\strata\Archive\ArchiveManifest

Reads the manifest out of an archive.

Parameters

\Drupal\Core\Archiver\ArchiveTar $archive

The open archive.

Throws

\RuntimeException

When the manifest is absent, unreadable, or from a later format than this release knows.

Returns

\Drupal\strata\Archive\ArchiveManifest —

The manifest.