@capacitor-community/sqlite 3.3.3-1 → 3.3.3-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -85,7 +85,9 @@ class UtilsSecret {
85
85
 
86
86
  // MARK: - SetEncryptionSecret
87
87
 
88
- class func setEncryptionSecret(passphrase: String) throws {
88
+ // swiftlint:disable function_body_length
89
+ class func setEncryptionSecret(passphrase: String,
90
+ databaseLocation: String) throws {
89
91
  do {
90
92
  if passphrase.isEmpty {
91
93
  let msg: String = "passphrase must not be empty"
@@ -102,13 +104,16 @@ class UtilsSecret {
102
104
  let dbList: [String] = try UtilsFile
103
105
  .getFileList(path: databaseURL.relativePath, ext: ".db")
104
106
  for file: String in dbList {
105
- let state: State = UtilsSQLCipher.getDatabaseState(databaseName: file)
107
+ let state: State = UtilsSQLCipher
108
+ .getDatabaseState(databaseLocation: databaseLocation,
109
+ databaseName: file)
106
110
  if state.rawValue == "ENCRYPTEDGLOBALSECRET" {
107
111
  let globalData: GlobalSQLite = GlobalSQLite()
108
112
  let password: String = globalData.secret
109
113
 
110
114
  let dbPath: String = try UtilsFile
111
- .getFilePath(fileName: file)
115
+ .getFilePath(databaseLocation: databaseLocation,
116
+ fileName: file)
112
117
  try UtilsSQLCipher.changePassword(filename: dbPath,
113
118
  password: password,
114
119
  newpassword: passphrase)
@@ -135,10 +140,14 @@ class UtilsSecret {
135
140
  }
136
141
 
137
142
  }
143
+ // swiftlint:enable function_body_length
138
144
 
139
145
  // MARK: - ChangeEncryptionSecret
140
146
 
141
- class func changeEncryptionSecret(passphrase: String, oldPassphrase: String) throws {
147
+ // swiftlint:disable function_body_length
148
+ class func changeEncryptionSecret(passphrase: String,
149
+ oldPassphrase: String,
150
+ databaseLocation: String) throws {
142
151
  do {
143
152
  if passphrase.isEmpty || oldPassphrase.isEmpty {
144
153
  let msg: String = "Passphrase and/or oldpassphrase must not " +
@@ -153,18 +162,22 @@ class UtilsSecret {
153
162
  let msg: String = "Given oldpassphrase is wrong"
154
163
  throw UtilsSecretError.changeEncryptionSecret(message: msg)
155
164
  }
156
- // get the list of databases
157
- let databaseURL: URL = try UtilsFile.getDatabasesUrl().absoluteURL
165
+ // get the list of databases from the database folder
166
+ let databaseURL: URL = try UtilsFile
167
+ .getFolderURL(folderPath: databaseLocation).absoluteURL
158
168
  var isDir = ObjCBool(true)
159
169
  if FileManager.default.fileExists(atPath: databaseURL.relativePath,
160
170
  isDirectory: &isDir) && isDir.boolValue {
161
171
  let dbList: [String] = try UtilsFile
162
172
  .getFileList(path: databaseURL.relativePath, ext: ".db")
163
173
  for file: String in dbList {
164
- let state: State = UtilsSQLCipher.getDatabaseState(databaseName: file)
174
+ let state: State = UtilsSQLCipher
175
+ .getDatabaseState(databaseLocation: databaseLocation,
176
+ databaseName: file)
165
177
  if state.rawValue == "ENCRYPTEDSECRET" {
166
178
  let dbPath: String = try UtilsFile
167
- .getFilePath(fileName: file)
179
+ .getFilePath(databaseLocation: databaseLocation,
180
+ fileName: file)
168
181
  try UtilsSQLCipher.changePassword(filename: dbPath,
169
182
  password: oldPassphrase,
170
183
  newpassword: passphrase)
@@ -193,5 +206,6 @@ class UtilsSecret {
193
206
  }
194
207
 
195
208
  }
209
+ // swiftlint:enable function_body_length
196
210
 
197
211
  }
@@ -33,10 +33,12 @@ class UtilsUpgrade {
33
33
 
34
34
  // swiftlint:disable cyclomatic_complexity
35
35
  // swiftlint:disable function_body_length
36
+ // swiftlint:disable function_parameter_count
36
37
  func onUpgrade(mDB: Database,
37
38
  upgDict: [Int: [String: Any]],
38
39
  dbName: String, currentVersion: Int,
39
- targetVersion: Int) throws -> Int {
40
+ targetVersion: Int,
41
+ databaseLocation: String) throws -> Int {
40
42
 
41
43
  var changes: Int = -1
42
44
  guard let upgrade: [String: Any] = upgDict[currentVersion]
@@ -76,7 +78,8 @@ class UtilsUpgrade {
76
78
  toggle: false)
77
79
  // backup the database
78
80
  _ = try UtilsFile.copyFile(fileName: dbName,
79
- toFileName: "backup-\(dbName)")
81
+ toFileName: "backup-\(dbName)",
82
+ databaseLocation: databaseLocation)
80
83
 
81
84
  let initChanges = UtilsSQLCipher.dbChanges(mDB: mDB.mDb)
82
85
 
@@ -121,6 +124,7 @@ class UtilsUpgrade {
121
124
  message: message)
122
125
  }
123
126
  }
127
+ // swiftlint:enable function_parameter_count
124
128
  // swiftlint:enable function_body_length
125
129
  // swiftlint:enable cyclomatic_complexity
126
130
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/sqlite",
3
- "version": "3.3.3-1",
3
+ "version": "3.3.3-2",
4
4
  "description": "Community plugin for native & electron SQLite databases",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",