From f8e00173404e3a6f04ad6eba39e667ae7c642495 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 22 Nov 2023 14:45:51 +0100 Subject: [PATCH] fixed an empty directory crashing the retention system --- nextcloud-upload/run.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nextcloud-upload/run.js b/nextcloud-upload/run.js index afca60a..a48c198 100644 --- a/nextcloud-upload/run.js +++ b/nextcloud-upload/run.js @@ -50,7 +50,7 @@ async function upload() { }); if (response.status != 404) { let data = JSON.parse(xml.toJson(response.data)); - let dirs = data["d:multistatus"]["d:response"].slice(1); + let dirs = data["d:multistatus"]["d:response"]?.slice(1) || []; // sort directories by last modified dirs.sort((a, b) => new Date(a["d:propstat"]["d:prop"]["d:getlastmodified"]) - new Date(b["d:propstat"]["d:prop"]["d:getlastmodified"])); while (dirs.length >= parseInt(retentionAmount)) {