Fix extremely slow removals

This commit is contained in:
Přemysl Eric Janouch 2024-12-29 13:41:07 +01:00
parent ca462ac005
commit ce2e58b6bc
Signed by: p
GPG Key ID: A0420B94F92B9493
2 changed files with 7 additions and 5 deletions

View File

@ -23,6 +23,7 @@ CREATE TABLE IF NOT EXISTS node(
) STRICT;
CREATE INDEX IF NOT EXISTS node__sha1 ON node(sha1);
CREATE INDEX IF NOT EXISTS node__parent ON node(parent);
CREATE UNIQUE INDEX IF NOT EXISTS node__parent_name
ON node(IFNULL(parent, 0), name);

11
main.go
View File

@ -94,10 +94,15 @@ func init() {
}
func openDB(directory string) error {
galleryDirectory = directory
var err error
db, err = sql.Open("sqlite3_custom", "file:"+filepath.Join(directory,
nameOfDB+"?_foreign_keys=1&_busy_timeout=1000"))
galleryDirectory = directory
if err != nil {
return err
}
_, err = db.Exec(initializeSQL)
return err
}
@ -303,10 +308,6 @@ func cmdInit(fs *flag.FlagSet, args []string) error {
return err
}
if _, err := db.Exec(initializeSQL); err != nil {
return err
}
// XXX: There's technically no reason to keep images as symlinks,
// we might just keep absolute paths in the database as well.
if err := os.MkdirAll(