Open the database with options suitable for the migration inserts. This is not a safe mode of operation for normal processing, use only for bulk inserts with a close afterwards.
(folder, path string, deleteRetention time.Duration)
| 63 | // is not a safe mode of operation for normal processing, use only for bulk |
| 64 | // inserts with a close afterwards. |
| 65 | func openFolderDBForMigration(folder, path string, deleteRetention time.Duration) (*folderDB, error) { |
| 66 | pragmas := []string{ |
| 67 | "journal_mode = OFF", |
| 68 | "foreign_keys = 0", |
| 69 | "synchronous = 0", |
| 70 | "locking_mode = EXCLUSIVE", |
| 71 | fmt.Sprintf("application_id = %d", applicationIDFolder), |
| 72 | } |
| 73 | schemas := []string{ |
| 74 | "sql/schema/common/*", |
| 75 | "sql/schema/folder/*", |
| 76 | } |
| 77 | |
| 78 | base, err := openBase(path, 1, pragmas, schemas, nil) |
| 79 | if err != nil { |
| 80 | return nil, err |
| 81 | } |
| 82 | |
| 83 | fdb := &folderDB{ |
| 84 | folderID: folder, |
| 85 | baseDB: base, |
| 86 | deleteRetention: deleteRetention, |
| 87 | } |
| 88 | |
| 89 | // Touch device IDs that should always exist and have a low index |
| 90 | // numbers, and will never change |
| 91 | fdb.localDeviceIdx, _ = fdb.deviceIdxLocked(protocol.LocalDeviceID) |
| 92 | fdb.tplInput["LocalDeviceIdx"] = fdb.localDeviceIdx |
| 93 | |
| 94 | return fdb, nil |
| 95 | } |
| 96 | |
| 97 | func (s *folderDB) deviceIdxLocked(deviceID protocol.DeviceID) (int64, error) { |
| 98 | devStr := deviceID.String() |
nothing calls this directly
no test coverage detected