From aa3e8913abaf2788d680d8ce81739286f54983b8 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Sun, 24 May 2020 10:36:26 +0800 Subject: [PATCH] Feat: add ".zip" suffix if not specified while creating compressed file --- service/explorer/objects.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/service/explorer/objects.go b/service/explorer/objects.go index 4944551..6275136 100644 --- a/service/explorer/objects.go +++ b/service/explorer/objects.go @@ -146,6 +146,11 @@ func (service *ItemCompressService) CreateCompressTask(c *gin.Context) serialize return serializer.Err(serializer.CodeGroupNotAllowed, "当前用户组无法进行此操作", nil) } + // 补齐压缩文件扩展名(如果没有) + if !strings.HasSuffix(service.Name, ".zip") { + service.Name += ".zip" + } + // 存放目录是否存在,是否重名 if exist, _ := fs.IsPathExist(service.Dst); !exist { return serializer.Err(serializer.CodeNotFound, "存放路径不存在", nil)