From 46c6941e2c1fba4195fb372753a644345826a815 Mon Sep 17 00:00:00 2001 From: han2015 <1019850453@qq.com> Date: Fri, 6 Jun 2025 13:09:40 +0800 Subject: [PATCH] download on single file directly --- code/rest/matter_service.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/code/rest/matter_service.go b/code/rest/matter_service.go index c6ab3c7..c2664e1 100644 --- a/code/rest/matter_service.go +++ b/code/rest/matter_service.go @@ -127,15 +127,17 @@ func (this *MatterService) DownloadZip( } } + destZipName := matters[0].Name + if len(matters) == 1 && !matters[0].Dir { + download.DownloadFile(writer, request, matters[0].AbsolutePath(), destZipName, true) + return + } + //prepare the temp zip dir destZipDirPath := fmt.Sprintf("%s/%d", GetUserZipRootDir(matters[0].Username), time.Now().UnixNano()/1e6) util.MakeDirAll(destZipDirPath) - destZipName := fmt.Sprintf("%s.zip", matters[0].Name) - if len(matters) > 1 || !matters[0].Dir { - destZipName = "archive.zip" - } - + destZipName = "archive.zip" destZipPath := fmt.Sprintf("%s/%s", destZipDirPath, destZipName) this.zipMatters(request, matters, destZipPath)