small cleanup

This commit is contained in:
AustrianToast 2024-06-11 00:18:41 +02:00
parent ee9708be55
commit 7b1b0f1cc5
No known key found for this signature in database
GPG Key ID: 5CD422268E489EB4

13
main.go
View File

@ -68,8 +68,6 @@ func main() {
}
func initUpload(c *gin.Context) {
var err error
fileName, err := io.ReadAll(c.Request.Body)
if err != nil {
c.JSON(http.StatusBadRequest, "Couldn't read html request body")
@ -141,19 +139,18 @@ func finishUpload(c *gin.Context) {
func listVideos(c *gin.Context) {
allVideos := map[int]string{}
var err error
rows, _ := dbpool.Query(context.Background(), "select * from videos")
for rows.Next() {
var id int
var filepath string
err = rows.Scan(&id, &filepath)
err := rows.Scan(&id, &filepath)
if err != nil {
c.JSON(http.StatusInternalServerError, "")
log.Panicf("listVideos: %v\n", err)
}
allVideos[id] = filepath
}
err = rows.Err()
err := rows.Err()
if err != nil {
c.JSON(http.StatusInternalServerError, "")
log.Panicf("listVideos: %v\n", err)
@ -163,10 +160,9 @@ func listVideos(c *gin.Context) {
}
func getVideo(c *gin.Context) {
var err error
rows, _ := dbpool.Query(context.Background(), "select filepath from videos where id = $1", c.Param("id"))
rows.Next()
err = rows.Err()
err := rows.Err()
if err != nil {
c.JSON(http.StatusInternalServerError, "")
log.Panicf("getVideo: %v\n", err)
@ -183,10 +179,9 @@ func getVideo(c *gin.Context) {
}
func deleteVideo(c *gin.Context) {
var err error
rows, _ := dbpool.Query(context.Background(), "select filepath from videos where id = $1", c.Param("id"))
rows.Next()
err = rows.Err()
err := rows.Err()
if err != nil {
c.JSON(http.StatusInternalServerError, "")
log.Panicf("deleteVideo: %v\n", err)