Skip to content

Commit 0dcd585

Browse files
committed
Fix issue#565
1 parent 6f50de2 commit 0dcd585

File tree

3 files changed

+32
-13
lines changed

3 files changed

+32
-13
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# 5.7.4 (2024-06-14)
2+
3+
### Bug Fixes
4+
5+
- Fix For-in loop requires 'Archive?' to conform to 'Sequence'; did you mean to unwrap optional? issue565
6+
7+
# 5.7.3 (2024-06-09)
8+
9+
### Bug Fixes
10+
11+
- Fix TypeError: Cannot read properties of undefined (reading 'lastId') issue#558
12+
- Fix exportToJson generate unusable export for table created with separate UNIQUE syntax. issue#561
13+
- Fix Multi Row Statement does not suppress control characters ($) issue#562
14+
115
# 5.7.3-3 (2024-04-28)
216

317
### Bug Fixes

ios/Plugin/Utils/UtilsDownloadFromHTTP.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,18 @@ class UtilsDownloadFromHTTP {
157157
}
158158
}
159159

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: {
162162
var dbFiles: [URL] = []
163163

164164
do {
165165
let destinationURL = zipFile.deletingLastPathComponent()
166166

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+
}
169172

170173
for entry in archive where entry.type == .file {
171174
let fileURL = destinationURL.appendingPathComponent(entry.path)
@@ -176,15 +179,14 @@ class UtilsDownloadFromHTTP {
176179
dbFiles.append(fileURL)
177180
}
178181
}
179-
180182
// Delete the zip file
181183
try FileManager.default.removeItem(at: zipFile)
182184

183185
completion(dbFiles, nil)
184186
} catch {
185-
let msg = "Failed in reading Archive: \(error.localizedDescription)"
186-
completion([], UtilsDownloadError.invalidArchive(message: msg))
187+
completion([], error)
187188
}
188-
}
189+
})
190+
189191
}
190192
}

ios/Plugin/Utils/UtilsFile.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,13 +421,15 @@ class UtilsFile {
421421

422422
}
423423

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 {
425426
do {
426427
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+
}
431433
let uDb: URL = try getFolderURL(folderPath: databaseLocation)
432434
for entry in archive {
433435
let dbEntry = setPathSuffix(sDb: entry.path)
@@ -440,6 +442,7 @@ class UtilsFile {
440442
}
441443
_ = try archive.extract(entry, to: zipCopy)
442444
}
445+
443446
} catch {
444447
let msg = "Error: Extracting \(entry.path) from archive failed \(error.localizedDescription)"
445448
print("\(msg)")

0 commit comments

Comments
 (0)