Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,23 @@ function handleApps(array $apps): void {
continue;
}

file_put_contents($cacheUrl, $data);
$tempUrl = tempnam(sys_get_temp_dir(), 'screenshot');
if ($tempUrl === false) {
// This should never happen, but just in case, treat this as an internal error
// Do nothing for now and try again later
continue;
}

file_put_contents($tempUrl, $data);

$mimeType = mime_content_type($cacheUrl);
$mimeType = mime_content_type($tempUrl);
if (!str_starts_with($mimeType, 'image/')) {
unlink($tempUrl);
generateWarningImage($cacheUrl, $url, 'Image not recognized');
continue;
}

rename($tempUrl, $cacheUrl);
echo(sprintf("Synced url %s\n", $url));
}
}
Expand Down