From aaac41e089e04c2872d3c42a7f0c93a4524c1548 Mon Sep 17 00:00:00 2001 From: John Niang Date: Mon, 28 Oct 2024 17:56:04 +0800 Subject: [PATCH] Fix the problem of not being able to upload if folder doesn't exist (#27) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the folder in AList doesn't exist, `failed get parent list: failed get dir: object not found` will be responded. Fixes https://github.com/halo-sigs/plugin-alist/issues/24 /kind bug ```release-note 修复文件夹不存在时无法正常上传文件 ``` --- .../java/run/halo/alist/endpoint/AListAttachmentHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/run/halo/alist/endpoint/AListAttachmentHandler.java b/src/main/java/run/halo/alist/endpoint/AListAttachmentHandler.java index c91dbaa..7adb447 100644 --- a/src/main/java/run/halo/alist/endpoint/AListAttachmentHandler.java +++ b/src/main/java/run/halo/alist/endpoint/AListAttachmentHandler.java @@ -279,7 +279,9 @@ private Mono getFile(String token, if (!Objects.equals(OK.value(), result.getCode())) { if (ignoreNotFound && Objects.equals(INTERNAL_SERVER_ERROR.value(), result.getCode()) - && "object not found".equals(result.getMessage())) { + // According to https://alist.nn.ci/guide/api/fs.html, we have no better + // way to determine whether the file exists + && StringUtils.endsWith(result.getMessage(), "object not found")) { return Mono.empty(); } return Mono.error(new ServerWebInputException(