Skip to content

Commit

Permalink
Adjust these
Browse files Browse the repository at this point in the history
  • Loading branch information
lancepioch committed Apr 15, 2024
1 parent 8ec4dc1 commit b70ab0e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 48 deletions.
16 changes: 6 additions & 10 deletions app/Repositories/Daemon/DaemonBackupRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ public function backup(Backup $backup)
return $this->getHttpClient()->post(
sprintf('/api/servers/%s/backup', $this->server->uuid),
[
'json' => [
'adapter' => $this->adapter ?? config('backups.default'),
'uuid' => $backup->uuid,
'ignore' => implode("\n", $backup->ignored_files),
],
'adapter' => $this->adapter ?? config('backups.default'),
'uuid' => $backup->uuid,
'ignore' => implode("\n", $backup->ignored_files),
]
);
} catch (TransferException $exception) {
Expand All @@ -60,11 +58,9 @@ public function restore(Backup $backup, string $url = null, bool $truncate = fal
return $this->getHttpClient()->post(
sprintf('/api/servers/%s/backup/%s/restore', $this->server->uuid, $backup->uuid),
[
'json' => [
'adapter' => $backup->disk,
'truncate_directory' => $truncate,
'download_url' => $url ?? '',
],
'adapter' => $backup->disk,
'truncate_directory' => $truncate,
'download_url' => $url ?? '',
]
);
} catch (TransferException $exception) {
Expand Down
2 changes: 1 addition & 1 deletion app/Repositories/Daemon/DaemonConfigurationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function update(Node $node)
try {
return $this->getHttpClient()->post(
'/api/update',
['json' => $node->getConfiguration()]
$node->getConfiguration(),
);
} catch (TransferException $exception) {
throw new DaemonConnectionException($exception);
Expand Down
62 changes: 26 additions & 36 deletions app/Repositories/Daemon/DaemonFileRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,8 @@ public function createDirectory(string $name, string $path)
return $this->getHttpClient()->post(
sprintf('/api/servers/%s/files/create-directory', $this->server->uuid),
[
'json' => [
'name' => $name,
'path' => $path,
],
'name' => $name,
'path' => $path,
]
);
} catch (TransferException $exception) {
Expand Down Expand Up @@ -151,9 +149,7 @@ public function copyFile(string $location)
return $this->getHttpClient()->post(
sprintf('/api/servers/%s/files/copy', $this->server->uuid),
[
'json' => [
'location' => $location,
],
'location' => $location,
]
);
} catch (TransferException $exception) {
Expand All @@ -174,10 +170,8 @@ public function deleteFiles(?string $root, array $files)
return $this->getHttpClient()->post(
sprintf('/api/servers/%s/files/delete', $this->server->uuid),
[
'json' => [
'root' => $root ?? '/',
'files' => $files,
],
'root' => $root ?? '/',
'files' => $files,
]
);
} catch (TransferException $exception) {
Expand All @@ -195,18 +189,17 @@ public function compressFiles(?string $root, array $files): array
Assert::isInstanceOf($this->server, Server::class);

try {
$response = $this->getHttpClient()->post(
sprintf('/api/servers/%s/files/compress', $this->server->uuid),
[
'json' => [
$response = $this->getHttpClient()
// Wait for up to 15 minutes for the archive to be completed when calling this endpoint
// since it will likely take quite awhile for large directories.
->timeout(60 * 15)
->post(
sprintf('/api/servers/%s/files/compress', $this->server->uuid),
[
'root' => $root ?? '/',
'files' => $files,
],
// Wait for up to 15 minutes for the archive to be completed when calling this endpoint
// since it will likely take quite awhile for large directories.
'timeout' => 60 * 15,
]
);
]
);
} catch (TransferException $exception) {
throw new DaemonConnectionException($exception);
}
Expand All @@ -224,18 +217,17 @@ public function decompressFile(?string $root, string $file)
Assert::isInstanceOf($this->server, Server::class);

try {
return $this->getHttpClient()->post(
sprintf('/api/servers/%s/files/decompress', $this->server->uuid),
[
'json' => [
return $this->getHttpClient()
// Wait for up to 15 minutes for the decompress to be completed when calling this endpoint
// since it will likely take quite awhile for large directories.
->timeout((int) CarbonInterval::minutes(15)->totalSeconds)
->post(
sprintf('/api/servers/%s/files/decompress', $this->server->uuid),
[
'root' => $root ?? '/',
'file' => $file,
],
// Wait for up to 15 minutes for the decompress to be completed when calling this endpoint
// since it will likely take quite awhile for large directories.
'timeout' => (int) CarbonInterval::minutes(15)->totalSeconds,
]
);
]
);
} catch (TransferException $exception) {
throw new DaemonConnectionException($exception);
}
Expand All @@ -254,10 +246,8 @@ public function chmodFiles(?string $root, array $files)
return $this->getHttpClient()->post(
sprintf('/api/servers/%s/files/chmod', $this->server->uuid),
[
'json' => [
'root' => $root ?? '/',
'files' => $files,
],
'root' => $root ?? '/',
'files' => $files,
]
);
} catch (TransferException $exception) {
Expand Down Expand Up @@ -286,7 +276,7 @@ public function pull(string $url, ?string $directory, array $params = [])
return $this->getHttpClient()->post(
sprintf('/api/servers/%s/files/pull', $this->server->uuid),
[
'json' => array_filter($attributes, fn ($value) => !is_null($value)),
array_filter($attributes, fn ($value) => !is_null($value)),
]
);
} catch (TransferException $exception) {
Expand Down
2 changes: 1 addition & 1 deletion app/Repositories/Daemon/DaemonPowerRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function send(string $action)
try {
return $this->getHttpClient()->post(
sprintf('/api/servers/%s/power', $this->server->uuid),
['json' => ['action' => $action]]
['action' => $action],
);
} catch (TransferException $exception) {
throw new DaemonConnectionException($exception);
Expand Down

0 comments on commit b70ab0e

Please sign in to comment.