MCPcopy Index your code
hub / github.com/syncthing/syncthing / openFolderDB

Function openFolderDB

internal/db/sqlite/folderdb_open.go:25–60  ·  view source on GitHub ↗
(folder, path string, deleteRetention time.Duration)

Source from the content-addressed store, hash-verified

23}
24
25func openFolderDB(folder, path string, deleteRetention time.Duration) (*folderDB, error) {
26 pragmas := []string{
27 "journal_mode = WAL",
28 "optimize = 0x10002",
29 "auto_vacuum = INCREMENTAL",
30 fmt.Sprintf("application_id = %d", applicationIDFolder),
31 }
32 schemas := []string{
33 "sql/schema/common/*",
34 "sql/schema/folder/*",
35 }
36 migrations := []string{
37 "sql/migrations/common/*",
38 "sql/migrations/folder/*",
39 }
40
41 base, err := openBase(path, maxDBConns, pragmas, schemas, migrations)
42 if err != nil {
43 return nil, err
44 }
45
46 fdb := &folderDB{
47 folderID: folder,
48 baseDB: base,
49 deleteRetention: deleteRetention,
50 }
51
52 _ = fdb.PutKV("folderID", []byte(folder))
53
54 // Touch device IDs that should always exist and have a low index
55 // numbers, and will never change
56 fdb.localDeviceIdx, _ = fdb.deviceIdxLocked(protocol.LocalDeviceID)
57 fdb.tplInput["LocalDeviceIdx"] = fdb.localDeviceIdx
58
59 return fdb, nil
60}
61
62// Open the database with options suitable for the migration inserts. This
63// is not a safe mode of operation for normal processing, use only for bulk

Callers

nothing calls this directly

Calls 3

deviceIdxLockedMethod · 0.95
openBaseFunction · 0.85
PutKVMethod · 0.65

Tested by

no test coverage detected