diff --git a/CHANGELOG.md b/CHANGELOG.md index fb659adf..b03f2360 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +# 5.7.4 (2024-06-14) + +### Bug Fixes + + - Fix For-in loop requires 'Archive?' to conform to 'Sequence'; did you mean to unwrap optional? issue565 + +# 5.7.3 (2024-06-09) + +### Bug Fixes + + - Fix TypeError: Cannot read properties of undefined (reading 'lastId') issue#558 + - Fix exportToJson generate unusable export for table created with separate UNIQUE syntax. issue#561 + - Fix Multi Row Statement does not suppress control characters ($) issue#562 + # 5.7.3-3 (2024-04-28) ### Bug Fixes diff --git a/ios/Plugin/Utils/UtilsDownloadFromHTTP.swift b/ios/Plugin/Utils/UtilsDownloadFromHTTP.swift index 3f746916..da3010a4 100644 --- a/ios/Plugin/Utils/UtilsDownloadFromHTTP.swift +++ b/ios/Plugin/Utils/UtilsDownloadFromHTTP.swift @@ -157,15 +157,18 @@ class UtilsDownloadFromHTTP { } } - class func extractDBFiles(from zipFile: URL, completion: @escaping ([URL], Error?) -> Void) { - DispatchQueue.global().async { + class func extractDBFiles(from zipFile: URL, completion: @escaping ([URL], Error?) -> Void) { + DispatchQueue.global().async(execute: { var dbFiles: [URL] = [] do { let destinationURL = zipFile.deletingLastPathComponent() - // Use the throwing initializer - let archive = try Archive(url: zipFile, accessMode: .read) + guard let archive = Archive(url: zipFile, accessMode: .read) else { + let msg = "Failed in reading Archive" + completion([], UtilsDownloadError.invalidArchive(message: msg)) + return + } for entry in archive where entry.type == .file { let fileURL = destinationURL.appendingPathComponent(entry.path) @@ -176,15 +179,14 @@ class UtilsDownloadFromHTTP { dbFiles.append(fileURL) } } - // Delete the zip file try FileManager.default.removeItem(at: zipFile) completion(dbFiles, nil) } catch { - let msg = "Failed in reading Archive: \(error.localizedDescription)" - completion([], UtilsDownloadError.invalidArchive(message: msg)) + completion([], error) } - } + }) + } } diff --git a/ios/Plugin/Utils/UtilsFile.swift b/ios/Plugin/Utils/UtilsFile.swift index 86a2dab3..9545c428 100644 --- a/ios/Plugin/Utils/UtilsFile.swift +++ b/ios/Plugin/Utils/UtilsFile.swift @@ -421,13 +421,15 @@ class UtilsFile { } - class func unzipToDatabase(fromURL: URL, databaseLocation: String, zip: String, overwrite: Bool) throws { + class func unzipToDatabase(fromURL: URL, databaseLocation: String, zip: String, + overwrite: Bool) throws { do { let zipAsset: URL = fromURL.appendingPathComponent(zip) - - // Use the throwing initializer - let archive = try Archive(url: zipAsset, accessMode: .read) - + guard let archive = Archive(url: zipAsset, accessMode: .read) else { + let msg = "Error: Read Archive: \(zipAsset) failed" + print("\(msg)") + throw UtilsFileError.unzipToDatabaseFailed(message: msg) + } let uDb: URL = try getFolderURL(folderPath: databaseLocation) for entry in archive { let dbEntry = setPathSuffix(sDb: entry.path) @@ -440,6 +442,7 @@ class UtilsFile { } _ = try archive.extract(entry, to: zipCopy) } + } catch { let msg = "Error: Extracting \(entry.path) from archive failed \(error.localizedDescription)" print("\(msg)")