mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Scene filename to metadata parser (#164)
* Initial UI prototype
* Add backend support to update multiple scenes
* Fix title editing issues
* Add query regex support. UI improvements
* Rewrite parser. Add fields button and page size
* Add helper text for escaping {} characters
* Validate date
* Only set values if different from original
* Only update scenes that have something changed
* Add built in parser input recipes
* Make pattern matching case-insensistive
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"github.com/gobuffalo/packr/v2"
|
||||
"github.com/golang-migrate/migrate/v4"
|
||||
"github.com/golang-migrate/migrate/v4/source"
|
||||
"github.com/jmoiron/sqlx"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
sqlite3 "github.com/mattn/go-sqlite3"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
"os"
|
||||
@@ -15,11 +17,16 @@ import (
|
||||
var DB *sqlx.DB
|
||||
var appSchemaVersion uint = 1
|
||||
|
||||
const sqlite3Driver = "sqlite3_regexp"
|
||||
|
||||
func Initialize(databasePath string) {
|
||||
runMigrations(databasePath)
|
||||
|
||||
// register custom driver with regexp function
|
||||
registerRegexpFunc()
|
||||
|
||||
// https://github.com/mattn/go-sqlite3
|
||||
conn, err := sqlx.Open("sqlite3", "file:"+databasePath+"?_fk=true")
|
||||
conn, err := sqlx.Open(sqlite3Driver, "file:"+databasePath+"?_fk=true")
|
||||
conn.SetMaxOpenConns(25)
|
||||
conn.SetMaxIdleConns(4)
|
||||
if err != nil {
|
||||
@@ -62,3 +69,16 @@ func runMigrations(databasePath string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func registerRegexpFunc() {
|
||||
regexFn := func(re, s string) (bool, error) {
|
||||
return regexp.MatchString(re, s)
|
||||
}
|
||||
|
||||
sql.Register(sqlite3Driver,
|
||||
&sqlite3.SQLiteDriver{
|
||||
ConnectHook: func(conn *sqlite3.SQLiteConn) error {
|
||||
return conn.RegisterFunc("regexp", regexFn, true)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user