@capacitor-community/sqlite 5.7.3 → 5.7.4

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.
@@ -157,15 +157,18 @@ class UtilsDownloadFromHTTP {
157
157
  }
158
158
  }
159
159
 
160
- class func extractDBFiles(from zipFile: URL, completion: @escaping ([URL], Error?) -> Void) {
161
- DispatchQueue.global().async {
160
+ class func extractDBFiles(from zipFile: URL, completion: @escaping ([URL], Error?) -> Void) {
161
+ DispatchQueue.global().async(execute: {
162
162
  var dbFiles: [URL] = []
163
163
 
164
164
  do {
165
165
  let destinationURL = zipFile.deletingLastPathComponent()
166
166
 
167
- // Use the throwing initializer
168
- let archive = try Archive(url: zipFile, accessMode: .read)
167
+ guard let archive = Archive(url: zipFile, accessMode: .read) else {
168
+ let msg = "Failed in reading Archive"
169
+ completion([], UtilsDownloadError.invalidArchive(message: msg))
170
+ return
171
+ }
169
172
 
170
173
  for entry in archive where entry.type == .file {
171
174
  let fileURL = destinationURL.appendingPathComponent(entry.path)
@@ -176,15 +179,14 @@ class UtilsDownloadFromHTTP {
176
179
  dbFiles.append(fileURL)
177
180
  }
178
181
  }
179
-
180
182
  // Delete the zip file
181
183
  try FileManager.default.removeItem(at: zipFile)
182
184
 
183
185
  completion(dbFiles, nil)
184
186
  } catch {
185
- let msg = "Failed in reading Archive: \(error.localizedDescription)"
186
- completion([], UtilsDownloadError.invalidArchive(message: msg))
187
+ completion([], error)
187
188
  }
188
- }
189
+ })
190
+
189
191
  }
190
192
  }
@@ -421,13 +421,15 @@ class UtilsFile {
421
421
 
422
422
  }
423
423
 
424
- class func unzipToDatabase(fromURL: URL, databaseLocation: String, zip: String, overwrite: Bool) throws {
424
+ class func unzipToDatabase(fromURL: URL, databaseLocation: String, zip: String,
425
+ overwrite: Bool) throws {
425
426
  do {
426
427
  let zipAsset: URL = fromURL.appendingPathComponent(zip)
427
-
428
- // Use the throwing initializer
429
- let archive = try Archive(url: zipAsset, accessMode: .read)
430
-
428
+ guard let archive = Archive(url: zipAsset, accessMode: .read) else {
429
+ let msg = "Error: Read Archive: \(zipAsset) failed"
430
+ print("\(msg)")
431
+ throw UtilsFileError.unzipToDatabaseFailed(message: msg)
432
+ }
431
433
  let uDb: URL = try getFolderURL(folderPath: databaseLocation)
432
434
  for entry in archive {
433
435
  let dbEntry = setPathSuffix(sDb: entry.path)
@@ -440,6 +442,7 @@ class UtilsFile {
440
442
  }
441
443
  _ = try archive.extract(entry, to: zipCopy)
442
444
  }
445
+
443
446
  } catch {
444
447
  let msg = "Error: Extracting \(entry.path) from archive failed \(error.localizedDescription)"
445
448
  print("\(msg)")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/sqlite",
3
- "version": "5.7.3",
3
+ "version": "5.7.4",
4
4
  "description": "Community plugin for native & electron SQLite databases",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",