Gofmt run and some database stuff

master
Noah Pederson 6 years ago
parent e70cdbe190
commit 863e4923fd
  1. 5
      .idea/libraries/GOPATH__gocomics_.xml
  2. 2
      .idea/misc.xml
  3. 6
      config/config.go
  4. 13
      database/database.go
  5. 3
      gocomics.go
  6. 2
      gocomics.iml
  7. 4
      models/comics.go
  8. 19
      scanner/comicscanner.go
  9. 1
      web/api.go
  10. 2
      web/comicstreamer.go
  11. 3
      web/web.go

@ -1,11 +1,10 @@
<component name="libraryTable">
<library name="GOPATH &lt;gocomics&gt;">
<CLASSES>
<root url="file://$PROJECT_DIR$/../../../gopkg.in" />
<root url="file://$PROJECT_DIR$/../../../github.com" />
<root url="file://$PROJECT_DIR$/../.." />
<root url="file://$PROJECT_DIR$/../../../golang.org" />
<root url="file://$PROJECT_DIR$/../../../9fans.net" />
<root url="file://$PROJECT_DIR$/../../../gopkg.in" />
<root url="file://$PROJECT_DIR$/../.." />
</CLASSES>
<JAVADOC />
<SOURCES />

@ -17,7 +17,7 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_3" default="false" assert-keyword="false" jdk-15="false" project-jdk-name="Go 1.6" project-jdk-type="Go SDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_3" default="false" assert-keyword="false" jdk-15="false" project-jdk-name="Go 1.6.2" project-jdk-type="Go SDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -1,8 +1,8 @@
package config
type ApiConfig struct {
UseTLS bool
UseTLS bool
ForceTLS bool
SSLPort string
SSLPort string
HttpPort string
}
}

@ -2,9 +2,9 @@ package database
import (
"database/sql"
"log"
_ "github.com/mattn/go-sqlite3"
"git.chiefnoah.tech/chiefnoah/gocomics/models"
_ "github.com/mattn/go-sqlite3"
"log"
)
var db *sql.DB
@ -143,14 +143,15 @@ func Init() {
}
func AddComic(comic models.ComicInfo) bool {
func AddComic(comic models.ComicInfo, file models.ComicFile) bool {
db, err := sql.Open("sqlite3", "./library.mdb")
if err != nil {
log.Fatal("Unable to open database: ", err)
}
INSERT_COMIC_INFO := "INSERT OR IGNORE INTO comic_info(filesize, date_added, hash) VALUES(?, ?, ?);"
//INSERT_COMIC := "INSERT OR IGNORE INTO comic(parentId, comicInfoId, fileName, path) VALUES ((SELECT id FROM folder WHERE path = ?), ?, ?, ?)"
INSERT_COMIC_FILE_INFO := `INSERT INTO ComicFile(RelativePath, AbsolutePath, Hash, Filesize) VALUES(?, ?, ?, ?)`
tx, err := db.Begin()
if err != nil {
@ -165,4 +166,4 @@ func AddComic(comic models.ComicInfo) bool {
defer stmt.Close()
return false
}
}

@ -16,8 +16,7 @@ func main() {
config := &config.ApiConfig{
false, false, ":3008", ":3000",
}
go comicscanner.Scan("./comics")
comicscanner.Scan("./comics")
web.Start(config)
}

@ -3,7 +3,7 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Go 1.6" jdkType="Go SDK" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="GOPATH &lt;gocomics&gt;" level="project" />
</component>

@ -4,7 +4,7 @@ package models
MGA database structures used for internal stuff
*/
type ComicInfo struct {
ID int `json:"id"`
ID int `json:"id"sql:"id"`
Title string `json:"title"`
Series string `json:"series"`
IssueNumber float32 `json:"issue_number"`
@ -19,7 +19,7 @@ type ComicInfo struct {
Rating float32 `json:"rating"`
Status string `json:"status"`
Bookmarks []int `json:"bookmarks"`
Other []string `json:"other"` ////Other tags are formatted "[tagname]:[tag]" semicolon delimited
Other []string `json:"other"` //Other tags are formatted "[tagname]:[tag]" semicolon delimited
}
type ComicFile struct {

@ -2,13 +2,14 @@ package comicscanner
import (
//"github.com/fsnotify/fsnotify"
"path"
"strings"
"path/filepath"
"os"
"fmt"
"crypto/md5"
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"
"log"
)
func Scan(f string) error {
@ -27,7 +28,11 @@ func visit(p string, f os.FileInfo, e error) error {
fmt.Printf("Found cbz file!\n")
//TODO: parse comic info
file, _ := ioutil.ReadFile(p)
file, err := ioutil.ReadFile(p)
if err != nil {
log.Print("Error: ", err)
return err
}
md5 := md5.Sum(file)
fmt.Printf("MD5: %x\n", md5)
@ -37,4 +42,4 @@ func visit(p string, f os.FileInfo, e error) error {
func watch(f []string) error {
return nil
}
}

@ -22,4 +22,3 @@ func Start(c *config.ApiConfig) {
func rootHandler(c *gin.Context) {
c.String(http.StatusOK, "hi")
}

@ -15,4 +15,4 @@ func versionHandler(c *gin.Context) {
func comicListHandler(c *gin.Context) {
}
}

@ -1,4 +1,3 @@
package web
//This is where the web user interface will go... whenever I eventually get to that
//This is where the web user interface will go... whenever I eventually get to that

Loading…
Cancel
Save