Skip to content

Commit

Permalink
Corrected SyncSampleAcrossUploadMWDBsIfExists
Browse files Browse the repository at this point in the history
logic.
  • Loading branch information
xorhex committed Oct 11, 2021
1 parent 47b896f commit 8ec8257
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ mlget.yml
go.sum
.mlget.yml
mlget.bak.yml
mlget-bak.yml
mlget-bak.yml
.vscode/*
4 changes: 3 additions & 1 deletion mlget.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ func main() {
fmt.Printf("\nLook up %s (%s)\n", h.Hash, h.HashType)

if (uploadToMWDBFlag || uploadToMWDBAndDeleteFlag) && !downloadOnlyFlag {
SyncSampleAcrossUploadMWDBsIfExists(cfg, h)
if SyncSampleAcrossUploadMWDBsIfExists(cfg, h) {
continue
}
}

if apiFlag != "" {
Expand Down
6 changes: 4 additions & 2 deletions upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ type CommentItemResponse struct {
Timestamp string `json:"timestamp"`
}

func SyncSampleAcrossUploadMWDBsIfExists(repos []RepositoryConfigEntry, hash Hash) {
func SyncSampleAcrossUploadMWDBsIfExists(repos []RepositoryConfigEntry, hash Hash) bool {
matchingConfigRepos := getConfigsByType(UploadMWDB, repos)
synced := false
for _, mcr := range matchingConfigRepos {
if !doesSampleExistInMWDB(mcr.Host, mcr.Api, hash.Hash) {
// If sample not found then skip the rest of this loop and check to see if the next UploadMWDB instance has the sample
Expand All @@ -47,8 +48,9 @@ func SyncSampleAcrossUploadMWDBsIfExists(repos []RepositoryConfigEntry, hash Has
AddCommentsToSamplesAcrossMWDBs(matchingConfigRepos, hash)
}
}
synced = true
}

return synced
}

func doesSampleExistInMWDB(uri string, api string, hash string) bool {
Expand Down

0 comments on commit 8ec8257

Please sign in to comment.