Skip to content

Commit

Permalink
FIX: Downloading duplicates due to query params in discord cdn links
Browse files Browse the repository at this point in the history
  • Loading branch information
get-got committed Feb 10, 2024
1 parent 837c979 commit bd67feb
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion downloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,21 @@ func pruneCompletedLinks(linkList map[string]string, m *discordgo.Message) map[s
newList := make(map[string]string, 0)
for link, filename := range linkList {
alreadyDownloaded := false
for _, downloadedFile := range dbFindDownloadByURL(link) {
testLink := link

parsedURL, err := url.Parse(testLink)
if err == nil {
if parsedURL.Hostname() == "cdn.discordapp.com" {
if strings.Contains(parsedURL.String(), "format=") {
parsedURL.RawQuery = "format=" + parsedURL.Query().Get("format")
} else {
parsedURL.RawQuery = ""
}
testLink = parsedURL.String()
}
}

for _, downloadedFile := range dbFindDownloadByURL(testLink) {
if downloadedFile.ChannelID == m.ChannelID {
alreadyDownloaded = true
}
Expand Down

0 comments on commit bd67feb

Please sign in to comment.