From bb52c24c31e09364e06163d9587b8ae655d7d74a Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Wed, 2 Oct 2019 17:14:14 -0400 Subject: [PATCH] fix meme saving. again. --- database.go | 8 +++++--- fun.go | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/database.go b/database.go index 9cf8ada..8b2d4d4 100644 --- a/database.go +++ b/database.go @@ -292,9 +292,11 @@ func savefile(xid string, name string, desc string, url string, media string, lo return 0, err } fileid, _ := res.LastInsertId() - _, err = stmtSaveFileData.Exec(xid, media, data) - if err != nil { - return 0, err + if local { + _, err = stmtSaveFileData.Exec(xid, media, data) + if err != nil { + return 0, err + } } return fileid, nil } diff --git a/fun.go b/fun.go index c58c529..abe824e 100644 --- a/fun.go +++ b/fun.go @@ -312,13 +312,13 @@ func memetize(honk *Honk) { fd.Close() url := fmt.Sprintf("https://%s/meme/%s", serverName, name) - res, err := stmtSaveFile.Exec("", name, name, url, ct, 0, "") + fileid, err := savefile("", name, name, url, ct, false, nil) if err != nil { log.Printf("error saving meme: %s", err) return x } var d Donk - d.FileID, _ = res.LastInsertId() + d.FileID = fileid d.XID = "" d.Name = name d.Media = ct