Skip to content

Commit

Permalink
断点续传修补
Browse files Browse the repository at this point in the history
  • Loading branch information
user1121114685 committed Mar 26, 2023
1 parent ddd7e2c commit 1e40318
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module 115push

go 1.20

require github.com/deadblue/elevengo v0.4.4
require github.com/deadblue/elevengo v0.4.5
10 changes: 5 additions & 5 deletions receiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func importFileForDir(dirid, url string, tickets *utils.FileList, wg *importer)
var err error
for i := 0; i < 20; i++ {
// 已经导入的部分 直接赋值
if *ticket.MakeDIrCid != "" {
id = *ticket.MakeDIrCid
if ticket.MakeDIrCid != "" {
id = ticket.MakeDIrCid
break
}
id, err = login.Agent.DirMake(dirid, ticket.ImportTicket.FileName)
Expand All @@ -76,7 +76,7 @@ func importFileForDir(dirid, url string, tickets *utils.FileList, wg *importer)
continue
}
// 没有新建文件夹的ID 新建一次文件夹并赋值
ticket.MakeDIrCid = &id
ticket.MakeDIrCid = id
break
}

Expand All @@ -90,14 +90,14 @@ func importFileForDir(dirid, url string, tickets *utils.FileList, wg *importer)
continue
}
// 如果已经导入 则跳过该文件
if *ticket.IsImport {
if ticket.IsImport {
continue
}

// 有时候发生了致命错误,然而不知道罪魁祸首,加上这个一目了然
log.Println("准备导入 " + ticket.ImportTicket.FileName)
err := login.Agent.Import(dirid, &ticket.ImportTicket)
*ticket.IsImport = true
ticket.IsImport = true
if err != nil {
if ie, ok := err.(*elevengo.ErrImportNeedCheck); ok {
signValue := getCalculateSignValue(url, ticket.PickCode, ie.SignRange)
Expand Down
4 changes: 2 additions & 2 deletions utils/fileList.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type SendFile struct {
PickCode string `json:"pickCode"`
IsDir bool `json:"IsDir" default:"false"`
// MakeDIrCid 如果是文件夹,则记录下文件夹的CID ---用于断点续传
MakeDIrCid *string `json:"MakeDIrCid"`
MakeDIrCid string `json:"MakeDIrCid"`
// IsImport 如果是文件,则记录下文件是否已经导入了。 --- 用于断点续传
IsImport *bool `json:"IsImport" default:"false"`
IsImport bool `json:"IsImport" default:"false"`
}

0 comments on commit 1e40318

Please sign in to comment.