From 410198c3788c216d4244d093eb923f6710f39c8f Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Sun, 24 Dec 2023 07:18:53 +0100 Subject: Cleanup --- main.go | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/main.go b/main.go index 970330d..a89a096 100644 --- a/main.go +++ b/main.go @@ -82,14 +82,14 @@ func thumbPath(sha1 string) string { nameOfThumbRoot, sha1[:2], sha1+".webp") } -func dbCollectStrings(query string) ([]string, error) { - rows, err := db.Query(query) +func dbCollectStrings(query string, a ...any) ([]string, error) { + rows, err := db.Query(query, a...) if err != nil { return nil, err } defer rows.Close() - var result []string + result := []string{} for rows.Next() { var s string if err := rows.Scan(&s); err != nil { @@ -288,23 +288,8 @@ func handleThumbs(w http.ResponseWriter, r *http.Request) { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - func getSubdirectories(tx *sql.Tx, parent int64) (names []string, err error) { - // TODO: This is like dbCollectStrings(), just needs an argument. - rows, err := tx.Query(`SELECT name FROM node + return dbCollectStrings(`SELECT name FROM node WHERE IFNULL(parent, 0) = ? AND sha1 IS NULL`, parent) - if err != nil { - return nil, err - } - defer rows.Close() - - names = []string{} - for rows.Next() { - var name string - if err := rows.Scan(&name); err != nil { - return nil, err - } - names = append(names, name) - } - return names, rows.Err() } type webEntry struct { -- cgit v1.2.3-70-g09d2