mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 13:09:00 +00:00
(live-capture) Handle failed screenshot fetch in BrowserlessClient
Return an empty byte array when screenshot fetch fails, ensuring downstream processes are not impacted by null responses. Additionally, only attempt to upload the screenshot if the byte array is non-empty, preventing invalid data from being stored.
This commit is contained in:
parent
ccf6b7caf3
commit
3dda8c228c
@ -74,6 +74,7 @@ public class BrowserlessClient implements AutoCloseable {
|
||||
|
||||
if (rsp.statusCode() >= 300) {
|
||||
logger.info("Failed to fetch screenshot for {}, status {}", url, rsp.statusCode());
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
return rsp.body();
|
||||
|
@ -170,7 +170,9 @@ public class LiveCaptureGrpcService
|
||||
byte[] pngBytes = client.screenshot(domain.toRootUrlHttps().toString(),
|
||||
BrowserlessClient.GotoOptions.defaultValues(),
|
||||
BrowserlessClient.ScreenshotOptions.defaultValues());
|
||||
ScreenshotDbOperations.uploadScreenshot(conn, domain, pngBytes);
|
||||
if (pngBytes.length > 0) {
|
||||
ScreenshotDbOperations.uploadScreenshot(conn, domain, pngBytes);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ScreenshotDbOperations.flagDomainAsFetched(conn, domain);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user