diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2023-12-24 07:18:53 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2023-12-24 07:18:53 +0100 |
commit | 410198c3788c216d4244d093eb923f6710f39c8f (patch) | |
tree | 11f961ebd1d6bff6c66a6e24e126bff05878e671 | |
parent | 0face97dc7b262986e206b5f3152e25a506f8326 (diff) | |
download | gallery-410198c3788c216d4244d093eb923f6710f39c8f.tar.gz gallery-410198c3788c216d4244d093eb923f6710f39c8f.tar.xz gallery-410198c3788c216d4244d093eb923f6710f39c8f.zip |
Cleanup
-rw-r--r-- | main.go | 23 |
1 files changed, 4 insertions, 19 deletions
@@ -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 { |