Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
moqsien committed May 23, 2024
1 parent 4727687 commit 0976a8a
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions internal/utils/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ type Sha256List map[string]string // fileName -> sha256
3. Delete file from remote repo
*/
type Uploader struct {
ShaFile string
VersionDir string
Github *gh.Github
Sha256List Sha256List
ShaFile string
VersionDir string
Github *gh.Github
Sha256List Sha256List
doNotSaveSha bool
}

func NewUploader() (u *Uploader) {
Expand All @@ -50,7 +51,7 @@ func (u *Uploader) loadSha256Info() {
}

func (u *Uploader) saveSha256Info() {
content, _ := json.Marshal(u.Sha256List)
content, _ := json.MarshalIndent(u.Sha256List, "", " ")
os.WriteFile(u.ShaFile, content, os.ModePerm)
}

Expand All @@ -73,15 +74,19 @@ func (u *Uploader) checkSha256(sdkName string, content []byte) (ok bool) {
}

if ss, ok1 := u.Sha256List[sdkName]; !ok1 {
u.Sha256List[sdkName] = shaStr
if !u.doNotSaveSha {
u.Sha256List[sdkName] = shaStr
}
u.saveSha256Info()
u.saveVersionFile(sdkName, content)
return true
} else {
if ss == shaStr {
return false
} else {
u.Sha256List[sdkName] = shaStr
if !u.doNotSaveSha {
u.Sha256List[sdkName] = shaStr
}
u.saveSha256Info()
u.saveVersionFile(sdkName, content)
return true
Expand All @@ -96,3 +101,7 @@ func (u *Uploader) Upload(sdkName string, content []byte) {
u.Github.UploadFile(remoteFilePath, localFilePath)
}
}

func (u *Uploader) DisableSaveSha256() {
u.doNotSaveSha = true
}

0 comments on commit 0976a8a

Please sign in to comment.