From e09a75a87cb19b796e3b29ffc7b22334cdf12afa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=AE=E5=87=89?= <927625802@qq.com> Date: Mon, 17 May 2021 16:36:55 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=20close=20#109=20=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B9=E8=BD=AF=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/models/create.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/server/models/create.go b/server/models/create.go index bf4258d5..fcd7e265 100644 --- a/server/models/create.go +++ b/server/models/create.go @@ -74,10 +74,35 @@ func BuildOne(parent string, path string, tx *gorm.DB, parentPassword string, dr marker = files.NextMarker for _, file := range files.Items { name := file.Name + password := parentPassword if strings.HasSuffix(name, ".hide") { continue } - password := parentPassword + if strings.Contains(name, ".ln-") { + index := strings.Index(name, ".ln-") + name = file.Name[:index] + fileId := file.Name[index+4:] + newFile := File{ + Dir: path, + FileExtension: "", + FileId: fileId, + Name: name, + Type: "folder", + UpdatedAt: file.UpdatedAt, + Category: "", + ContentType: "", + Size: 0, + Password: password, + } + log.Debugf("插入file:%+v", newFile) + if err = tx.Create(&newFile).Error; err != nil { + return err + } + if err = BuildOne(fileId, fmt.Sprintf("%s%s/", path, name), tx, password, drive, depth-1); err != nil { + return err + } + continue + } if strings.Contains(name, ".password-") { index := strings.Index(name, ".password-") name = file.Name[:index]