feat(admin): единые процентные веса без старого формата (#28)
This commit is contained in:
1 parent
a22519e754
commit
47405b27d8
21 files changed
+326
-46
No files matched your search
@@ -75,10 +75,16 @@ final class Transport
|
||||
if(!is_string($key)||!hash_equals(rtrim($expected,'='),rtrim(str_starts_with($expected,'SHA256:')?$fp:$key,'=')))throw new Problem('Ключ SFTP хоста не совпадает.');
|
||||
$secret=$t['secret'];if(str_contains($secret,'PRIVATE KEY'))$secret=PublicKeyLoader::loadPrivateKey($secret);if(!$sftp->login($t['user'],$secret))throw new Problem('Не удалось войти в SFTP.');return $sftp;
|
||||
}
|
||||
public function test(): array {return $this->call(['op'=>'test']);}
|
||||
public function test(): array {
|
||||
$result=$this->call(['op'=>'test']);
|
||||
$read=$this->readConfig();
|
||||
if (!hash_equals($result['version'],$read['version'])) throw new Conflict();
|
||||
PercentWeights::validate($read['config']);
|
||||
return $result;
|
||||
}
|
||||
public function readConfig(): array {$r=$this->call(['op'=>'read']);return ['config'=>Config::decode($r['content']),'version'=>$r['version'],'content'=>$r['content']];}
|
||||
public function writeConfig(string $version,string $content): array {
|
||||
Config::assertWritable(Config::decode($content));
|
||||
$config=Config::decode($content);Config::assertWritable($config);PercentWeights::validate($config);
|
||||
$before=$this->call(['op'=>'read']);if(!hash_equals($version,$before['version']))throw new Conflict();
|
||||
$this->store->backup($this->target['id'],$before['content']);
|
||||
return $this->call(['op'=>'write','version'=>$version,'content'=>$content]);
|
||||
|
||||
Reference in new issue
Block a user