diff options
Diffstat (limited to 'main.go')
-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 { |