1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00

Removed haspassword

Former-commit-id: 4670fa4a1dc343c501f8f76421fa51b54d450cd3 [formerly e3b56e6823a77a388881b388f8f7fff348c04cba] [formerly e8bd41425d5b0a377d0ff687fcead01cab38c98c [formerly a4b29de724db196efc8505bff0b990b469bce019 [formerly 4ffcc1abd5]]]
Former-commit-id: 0850667d5b0245328ca38933359006101d14e9d6 [formerly e7643ddbfe5ec74936760a4b6ffbaeeb71a93275]
Former-commit-id: be2765befe8951bc772c0c04a0583911446c8bb7
Former-commit-id: f12d53de63
This commit is contained in:
Zack Scholl 2016-03-28 19:29:48 -04:00
parent 0f31132a8a
commit b4e3628008

37
db.go
View File

@ -43,43 +43,6 @@ type WikiData struct {
Locked string
}
func hasPassword(title string) (bool, error) {
title = strings.ToLower(title)
if !open {
Open(RuntimeArgs.DatabaseLocation)
defer Close()
}
hasPassword := false
err := db.View(func(tx *bolt.Tx) error {
var err error
b := tx.Bucket([]byte("datas"))
if b == nil {
return fmt.Errorf("db must be opened before loading")
}
k := []byte(title)
val := b.Get(k)
if val == nil {
return nil
}
var p WikiData
err = p.decode(val)
if err != nil {
return err
}
for _, line := range strings.Split(p.CurrentText, "\n") {
if strings.Contains(line, "<") == true && strings.Contains(line, ">") == true && strings.Contains(line, "user") == true && strings.Contains(line, "password") == true && strings.Contains(line, "public") == true {
hasPassword = true
}
}
return nil
})
if err != nil {
fmt.Printf("Could not get WikiData: %s", err)
return false, err
}
return hasPassword, nil
}
func getCurrentText(title string, version int) (string, []versionsInfo, bool, time.Duration, bool, string) {
Open(RuntimeArgs.DatabaseLocation)
defer Close()