@capacitor-community/sqlite 6.0.0 → 6.0.1
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.
|
@@ -158,14 +158,17 @@ class UtilsDownloadFromHTTP {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
class func extractDBFiles(from zipFile: URL, completion: @escaping ([URL], Error?) -> Void) {
|
|
161
|
-
DispatchQueue.global().async {
|
|
161
|
+
DispatchQueue.global().async(execute: {
|
|
162
162
|
var dbFiles: [URL] = []
|
|
163
163
|
|
|
164
164
|
do {
|
|
165
165
|
let destinationURL = zipFile.deletingLastPathComponent()
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
429
|
-
|
|
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)")
|