校验option restore

@param string $restore
@throws OssException
3264
private function precheckStorage($storage)
    {
        if (is_string($storage)) {
            switch ($storage) {
                case self::OSS_STORAGE_ARCHIVE:
                    return;
                case self::OSS_STORAGE_IA:
                    return;
                case self::OSS_STORAGE_STANDARD:
                    return;
                default:
                    break;
            }
        }
        throw new OssException('storage name is invalid');
    }
489917
public function restore()
    {
        if ($this->backup instanceof NotSet) {
            if (is_file($this->name)) {
                unlink($this->name);
            }
        } else {
            file_put_contents($this->name, $this->backup);
        }
    }
65597
public function register($restore = true, $type = E_ALL | E_STRICT, $shutdown = false)
    {
        if ($type === null) {
            $type = E_ALL | E_STRICT;
        }

        if ($restore) {
            $this->restore();
        }

        set_error_handler([$this, 'error'], $type);
        set_exception_handler([$this, 'exception']);

        if ($shutdown) {
            register_shutdown_function([$this, 'down']);
        }
    }
470167
public function after_restore() {
        global $DB;

        // Get the blockid.
        $blockid = $this->get_blockid();

        if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $blockid))) {
            $config = unserialize(base64_decode($configdata));
            if (!empty($config->activityparentid)) {
                // Get the mapping and replace it in config.
                if ($mapping = restore_dbops::get_backup_ids_record($this->get_restoreid(),
                    $config->activityparent, $config->activityparentid)) {

                    // Update the parent module id (the id from mdl_quiz etc...)
                    $config->activityparentid = $mapping->newitemid;

                    // Get the grade_items record to update the activitygradeitemid.
                    $info = $DB->get_record('grade_items',
                            array('iteminstance' => $config->activityparentid, 'itemmodule' => $config->activityparent));

                    // Update the activitygradeitemid the id from the grade_items table.
                    $config->activitygradeitemid = $info->id;

                    // Encode and save the config.
                    $configdata = base64_encode(serialize($config));
                    $DB->set_field('block_instances', 'configdata', $configdata, array('id' => $blockid));
                }
            }
        }
    }
1242833
public static function restore(string $fileName = self::FILENAME_CONFIG_DEFAULT): ApiContext
    {
        $contextJsonString = self::getContextJsonString($fileName);

        return static::fromJson($contextJsonString);
    }
475905
private function restoreNode(
        NodeInterface $node,
        NodeInterface $frozenNode,
        $contentPropertyPrefix,
        $systemPropertyPrefix
    ) {
        // remove the properties for the given language, so that values being added since the last version are removed
        foreach ($node->getProperties() as $property) {
            if ($this->isRestoreProperty($property->getName(), $contentPropertyPrefix, $systemPropertyPrefix)) {
                $property->remove();
            }
        }

        // set all the properties from the saved version to the node
        foreach ($frozenNode->getPropertiesValues() as $name => $value) {
            if ($this->isRestoreProperty($name, $contentPropertyPrefix, $systemPropertyPrefix)) {
                $node->setProperty($name, $value);
            }
        }

        /** @var NodeInterface $childNode */
        foreach ($frozenNode->getNodes() as $childNode) {
            // create new node if it not exists
            if (!$node->hasNode($childNode->getName())) {
                $newNode = $node->addNode($childNode->getName());
                $newNode->setMixins($childNode->getPropertyValueWithDefault('jcr:frozenMixinTypes', []));
            }

            $this->restoreNode(
                $node->getNode($childNode->getName()),
                $childNode,
                $contentPropertyPrefix,
                $systemPropertyPrefix
            );
        }

        // remove child-nodes which do not exists in frozen-node
        foreach ($node->getNodes() as $childNode) {
            if (OnParentVersionAction::COPY !== $childNode->getDefinition()->getOnParentVersion()
                || $frozenNode->hasNode($childNode->getName())
            ) {
                continue;
            }

            $childNode->remove();
        }
    }
256957
protected void performRestoreOperation() throws CmsException {

        CmsUUID structureId = new CmsUUID(getSelectedItem().get(LIST_COLUMN_STRUCTURE_ID).toString());
        int version = Integer.parseInt(getSelectedItems().get(0).getId());
        if (version == CmsHistoryResourceHandler.PROJECT_OFFLINE_VERSION) {
            // it is not possible to restore the offline version
            return;
        }
        CmsResource res = getCms().readResource(structureId, CmsResourceFilter.IGNORE_EXPIRATION);
        checkLock(getCms().getSitePath(res));
        getCms().restoreResourceVersion(res.getStructureId(), version);
    }
419902
public function restore(string $filename, int $days): RestoreCommand
    {
        /** @var RestoreCommand $command */
        $command = $this->builder->build(RestoreCommand::class);
        $command->byFilename($filename)->withLifetime($days);

        return $command;
    }
1016652
protected void restore(ObjectInputStream ois, int dataVersion) throws SevereMessageStoreException
  
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "restore", new Object[] { dataVersion});
    checkPersistentVersionId(dataVersion);
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "restore");
  }
1010377
public function sign($key, $password = null)
    {
        OpenSslException::reset();

        if (false === extension_loaded('openssl')) {
            // @codeCoverageIgnoreStart
            throw OpenSslException::create(
                'The "openssl" extension is not available.'
            );
            // @codeCoverageIgnoreEnd
        }

        if (false === ($resource = openssl_pkey_get_private($key, $password))) {
            // @codeCoverageIgnoreStart
            throw OpenSslException::lastError();
            // @codeCoverageIgnoreEnd
        }

        if (false === openssl_pkey_export($resource, $private)) {
            // @codeCoverageIgnoreStart
            throw OpenSslException::lastError();
            // @codeCoverageIgnoreEnd
        }

        if (false === ($details = openssl_pkey_get_details($resource))) {
            // @codeCoverageIgnoreStart
            throw OpenSslException::lastError();
            // @codeCoverageIgnoreEnd
        }

        $this->phar->setSignatureAlgorithm(Phar::OPENSSL, $private);

        if (false === @file_put_contents($this->file . '.pubkey', $details['key'])) {
            throw FileException::lastError();
        }
    }
672881
public function restoreProperties(RestoreEvent $event)
    {
        if (!$this->support($event->getDocument())) {
            $event->stopPropagation();

            return;
        }

        $contentPropertyPrefix = $this->propertyEncoder->localizedContentName('', $event->getLocale());
        $systemPropertyPrefix = $this->propertyEncoder->localizedSystemName('', $event->getLocale());

        $node = $event->getNode();

        try {
            $version = $this->versionManager->getVersionHistory($node->getPath())->getVersion($event->getVersion());

            $frozenNode = $version->getFrozenNode();

            $this->restoreNode($node, $frozenNode, $contentPropertyPrefix, $systemPropertyPrefix);
        } catch (VersionException $exception) {
            throw new VersionNotFoundException($event->getDocument(), $event->getVersion());
        }
    }
1259066
def restore(self, key, ttl, value):
        """"""
        return self.execute(b'RESTORE', key, ttl, value)
854960
public function transact(callable $transactionFn, $restoreOnFalseReturn = false)
    {
        $state = $this->captureState();
        try {
            $retval = call_user_func($transactionFn);
        } catch (\Exception $ex) {
            $state->restore();
            throw $ex;
        }

        if ($restoreOnFalseReturn && false === $retval) {
            $state->restore();
        }

        return $retval;
    }
1003282
function restore(options) {
  options = _.defaults(options || {}, {
    stdout: true,
    stderr: true
  });

  if (options.stdout)
    process.stdout.write = originalWrites.stdout;

  if (options.stderr)
    process.stderr.write = originalWrites.stderr;
}
396425
public function restore($id, $callback = null)
    {
        $model = $this->query()->withTrashed()->find($id);

        if (is_null($model->deleted_at)) {
            throw new GeneralException('该数据未删除，因此无法恢复。');
        }

        DB::transaction(function () use ($model, $callback) {
            if ($model->restore()) {
                if ($callback instanceof Closure) {
                    $callback($model);
                }

                return true;
            }

            throw new GeneralException($model, '还原时出现问题，请再试一次。');
        });

        return $model;
    }
498420
public static base_response restore(nitro_service client, systembackup resource) throws Exception {
		systembackup restoreresource = new systembackup();
		restoreresource.filename = resource.filename;
		return restoreresource.perform_operation(client,"restore");
	}
36250
public function actionRestore()
    {
        $model = new Restore($this->getModule()->dbList);
        if (is_null($this->file)) {
            if ($this->storage) {
                if (Yii::$app->has('backupStorage')) {
                    foreach (Yii::$app->backupStorage->listContents() as $file) {
                        $fileList[] = [
                            'basename' => $file['basename'],
                            'timestamp' => $file['timestamp'],
                        ];
                    }
                } else {
                    Console::output('Storage component is not configured.');
                }
            } else {
                foreach ($this->getModule()->getFileList() as $file) {
                    $fileList[] = [
                        'basename' => StringHelper::basename($file),
                        'timestamp' => filectime($file),
                    ];
                }
            }
            ArrayHelper::multisort($fileList, ['timestamp'], [SORT_DESC]);
            $this->file = ArrayHelper::getValue(array_shift($fileList), 'basename');
        }
        $runtime = null;
        $dumpFile = null;
        if ($this->storage) {
            if (Yii::$app->has('backupStorage')) {
                if (Yii::$app->backupStorage->has($this->file)) {
                    $runtime = Yii::getAlias('@runtime/backups');
                    if (!is_dir($runtime)) {
                        FileHelper::createDirectory($runtime);
                    }
                    $dumpFile = $runtime . '/' . $this->file;
                    file_put_contents($dumpFile, Yii::$app->backupStorage->read($this->file));
                } else {
                    Console::output('File not found.');
                }
            } else {
                Console::output('Storage component is not configured.');
            }
        } else {
            $fileExists = $this->getModule()->path . $this->file;
            if (file_exists($fileExists)) {
                $dumpFile = $fileExists;
            } else {
                Console::output('File not found.');
            }
        }
        if (ArrayHelper::isIn($this->db, $this->getModule()->dbList)) {
            $dbInfo = $this->getModule()->getDbInfo($this->db);
            $restoreOptions = $model->makeRestoreOptions();
            $manager = $this->getModule()->createManager($dbInfo);
            $restoreCommand = $manager->makeRestoreCommand($dumpFile, $dbInfo, $restoreOptions);
            Yii::trace(compact('restoreCommand', 'dumpFile', 'restoreOptions'), get_called_class());
            $process = new Process($restoreCommand);
            $process->run();
            if (!is_null($runtime)) {
                FileHelper::removeDirectory($runtime);
            }
            if ($process->isSuccessful()) {
                Console::output('Dump successfully restored.');
            } else {
                Console::output('Dump failed restored.');
            }
        } else {
            Console::output('Database configuration not found.');
        }
    }