Properly handle 404 for editing files (#816)

This commit is contained in:
Boy132
2024-12-12 18:26:01 +01:00
committed by GitHub
parent 026494c353
commit 771eece01e
3 changed files with 19 additions and 10 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Repositories\Daemon;
use Carbon\CarbonInterval;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Http\Client\Response;
use Webmozart\Assert\Assert;
use App\Models\Server;
@@ -21,6 +22,7 @@ class DaemonFileRepository extends DaemonRepository
* @throws \GuzzleHttp\Exception\TransferException
* @throws \App\Exceptions\Http\Server\FileSizeTooLargeException
* @throws \App\Exceptions\Http\Connection\DaemonConnectionException
* @throws FileNotFoundException
*/
public function getContent(string $path, ?int $notLargerThan = null): string
{
@@ -40,6 +42,10 @@ class DaemonFileRepository extends DaemonRepository
throw new FileSizeTooLargeException();
}
if ($response->getStatusCode() === 404) {
throw new FileNotFoundException();
}
return $response;
}