From f7415cee6819c4e9d2e39a56ba16a4867e0885ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20K=C5=82os?= Date: Thu, 4 Mar 2021 10:12:05 +0100 Subject: [PATCH] Provide capabilities.json directly in a proxy.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid file read. Do not run appimage to extract data as it doesn't change too often. Signed-off-by: Szymon Kłos --- build-nextcloud-app.sh | 5 ----- proxy.php | 19 ++++++++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/build-nextcloud-app.sh b/build-nextcloud-app.sh index 871fcef..8d348a6 100755 --- a/build-nextcloud-app.sh +++ b/build-nextcloud-app.sh @@ -49,11 +49,6 @@ HASH=`./${app_name}/collabora/Collabora_Online.AppImage --version-hash` echo "HASH: $HASH" sed "s/%LOOLWSD_VERSION_HASH%/$HASH/g" ../proxy.php > ${app_name}/proxy.php -# Fetch capabilities from AppImage for cache -PID_FILE="/tmp/loolwsd.pid" -`./${app_name}/collabora/Collabora_Online.AppImage 2>/dev/null` & (sleep 3 && curl "http://localhost:9983/hosting/capabilities" --max-time 10 -o "${app_name}/capabilities.json") || (echo && echo "ERROR: Cannot fetch capabilities!" && echo) -kill -9 `cat $PID_FILE` 2>/dev/null || (echo && echo "Failed to run Collabora Online Appimage" && echo) - # check if we are building for arm64 if [[ "$APPIMAGE_URL" =~ "arm64" ]]; then echo "Building for arm64" diff --git a/proxy.php b/proxy.php index 16a23f0..c7ccbaf 100644 --- a/proxy.php +++ b/proxy.php @@ -206,15 +206,20 @@ function getallheaders() if ($request == '' && !$statusOnly) errorExit("Missing, required req= parameter"); -if (startsWith($request, '/hosting/capabilities') && !isLoolwsdRunning() && file_exists('capabilities.json')) { +if (startsWith($request, '/hosting/capabilities') && !isLoolwsdRunning()) { header('Content-type: application/json'); header('Cache-Control: no-store'); - $capabilities = file_get_contents('capabilities.json'); - if ($capabilities !== false) { - print $capabilities; - http_response_code(200); - exit(); - } + + print '{ + "convert-to":{"available":true}, + "hasMobileSupport":true, + "hasProxyPrefix":false, + "hasTemplateSaveAs":false, + "hasTemplateSource":true + }'; + + http_response_code(200); + exit(); } // If we can't get a socket open in 3 seconds when that is backed by