Skip to content

Commit

Permalink
Update content key only if content was found
Browse files Browse the repository at this point in the history
  • Loading branch information
llemeurfr committed Dec 28, 2024
1 parent ebbc194 commit e072266
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lcpencrypt/get_content_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,18 @@ func getContentKey(contentKey *string, contentID, lcpsv string, v2 bool, usernam
}
defer resp.Body.Close()

contentInfo := ContentInfo{}
dec := json.NewDecoder(resp.Body)
err = dec.Decode(&contentInfo)
if err != nil {
return errors.New("unable to decode content information")
}
// if the content is found, the content key is updated
if resp.StatusCode == http.StatusOK {
contentInfo := ContentInfo{}
dec := json.NewDecoder(resp.Body)
err = dec.Decode(&contentInfo)
if err != nil {
return errors.New("unable to decode content information")
}

*contentKey = b64.StdEncoding.EncodeToString(contentInfo.EncryptionKey)

fmt.Println("Existing encryption key retrieved")
*contentKey = b64.StdEncoding.EncodeToString(contentInfo.EncryptionKey)
fmt.Println("Existing encryption key retrieved")
}
return nil
}

Expand Down

0 comments on commit e072266

Please sign in to comment.