chore(sqlite): stamp files with application_id
No practical effect, just a tiny bit of fun to stamp the database files with an application ID that identifies them. Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
@@ -25,7 +25,11 @@ import (
|
|||||||
"github.com/syncthing/syncthing/lib/protocol"
|
"github.com/syncthing/syncthing/lib/protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
const currentSchemaVersion = 4
|
const (
|
||||||
|
currentSchemaVersion = 4
|
||||||
|
applicationIDMain = 0x53546d6e // "STmn", Syncthing main database
|
||||||
|
applicationIDFolder = 0x53546664 // "STfd", Syncthing folder database
|
||||||
|
)
|
||||||
|
|
||||||
//go:embed sql/**
|
//go:embed sql/**
|
||||||
var embedded embed.FS
|
var embedded embed.FS
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
package sqlite
|
package sqlite
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -52,6 +53,7 @@ func Open(path string, opts ...Option) (*DB, error) {
|
|||||||
"journal_mode = WAL",
|
"journal_mode = WAL",
|
||||||
"optimize = 0x10002",
|
"optimize = 0x10002",
|
||||||
"auto_vacuum = INCREMENTAL",
|
"auto_vacuum = INCREMENTAL",
|
||||||
|
fmt.Sprintf("application_id = %d", applicationIDMain),
|
||||||
}
|
}
|
||||||
schemas := []string{
|
schemas := []string{
|
||||||
"sql/schema/common/*",
|
"sql/schema/common/*",
|
||||||
@@ -100,6 +102,7 @@ func OpenForMigration(path string) (*DB, error) {
|
|||||||
"foreign_keys = 0",
|
"foreign_keys = 0",
|
||||||
"synchronous = 0",
|
"synchronous = 0",
|
||||||
"locking_mode = EXCLUSIVE",
|
"locking_mode = EXCLUSIVE",
|
||||||
|
fmt.Sprintf("application_id = %d", applicationIDMain),
|
||||||
}
|
}
|
||||||
schemas := []string{
|
schemas := []string{
|
||||||
"sql/schema/common/*",
|
"sql/schema/common/*",
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
package sqlite
|
package sqlite
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/syncthing/syncthing/lib/protocol"
|
"github.com/syncthing/syncthing/lib/protocol"
|
||||||
@@ -25,6 +26,7 @@ func openFolderDB(folder, path string, deleteRetention time.Duration) (*folderDB
|
|||||||
"journal_mode = WAL",
|
"journal_mode = WAL",
|
||||||
"optimize = 0x10002",
|
"optimize = 0x10002",
|
||||||
"auto_vacuum = INCREMENTAL",
|
"auto_vacuum = INCREMENTAL",
|
||||||
|
fmt.Sprintf("application_id = %d", applicationIDFolder),
|
||||||
}
|
}
|
||||||
schemas := []string{
|
schemas := []string{
|
||||||
"sql/schema/common/*",
|
"sql/schema/common/*",
|
||||||
@@ -65,6 +67,7 @@ func openFolderDBForMigration(folder, path string, deleteRetention time.Duration
|
|||||||
"foreign_keys = 0",
|
"foreign_keys = 0",
|
||||||
"synchronous = 0",
|
"synchronous = 0",
|
||||||
"locking_mode = EXCLUSIVE",
|
"locking_mode = EXCLUSIVE",
|
||||||
|
fmt.Sprintf("application_id = %d", applicationIDFolder),
|
||||||
}
|
}
|
||||||
schemas := []string{
|
schemas := []string{
|
||||||
"sql/schema/common/*",
|
"sql/schema/common/*",
|
||||||
|
|||||||
Reference in New Issue
Block a user