mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
Removed haspassword
This commit is contained in:
parent
600dd685f1
commit
4ffcc1abd5
37
db.go
37
db.go
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user