fix misdetection of every file being changed every time

This commit is contained in:
Greyscale 2024-01-25 16:02:53 +01:00
parent 17b0665893
commit 3262ff3791
No known key found for this signature in database
GPG key ID: 74BAFF55434DA4B2
2 changed files with 16 additions and 2 deletions

View file

@ -716,8 +716,9 @@ class Bouncer
}
if ($target->hasAuth()) {
$authFileHash = $this->configFilesystem->fileExists($target->getAuthFileName()) ? sha1($this->configFilesystem->read($target->getAuthFileName())) : null;
if (sha1($target->getAuthFileData()) != $authFileHash) {
$authFileHash = $this->configFilesystem->fileExists($target->getAuthFileName()) ? $this->configFilesystem->read($target->getAuthFileName()) : null;
if ($target->getAuthHash() != $authFileHash) {
$this->configFilesystem->write($target->getAuthFileName() . '.hash', $target->getAuthHash());
$this->configFilesystem->write($target->getAuthFileName(), $target->getAuthFileData());
$changed = true;
}

View file

@ -98,6 +98,19 @@ class Target
return $this;
}
public function getAuth(): array
{
return [
'username' => $this->getUsername(),
'password' => $this->getPassword(),
];
}
public function getAuthHash(): string
{
return sha1(implode(':', $this->getAuth()));
}
public function setAuth(string $username, string $password): self
{
return $this->setUsername($username)->setPassword($password);