Skip to content

Commit 3036c85

Browse files
committed
fix issue#565
1 parent 96c29ea commit 3036c85

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
# 6.0.0 (2024-06-12)
1+
# 6.0.1 (2024-06-14)
2+
3+
### Bug Fixes
24

5+
- Fix For-in loop requires 'Archive?' to conform to 'Sequence'; did you mean to unwrap optional? issue565
6+
7+
# 6.0.0 (2024-06-12)
38

49

510
# 6.0.0-beta.2 (2024-06-12)
@@ -23,6 +28,12 @@
2328
- Add the fixes of 5.7.3
2429

2530

31+
# 5.7.4 (2024-06-14)
32+
33+
### Bug Fixes
34+
35+
- Fix For-in loop requires 'Archive?' to conform to 'Sequence'; did you mean to unwrap optional? issue565
36+
2637
# 5.7.3 (2024-06-09)
2738

2839
### Bug Fixes

ios/Plugin/Utils/UtilsDownloadFromHTTP.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,17 @@ class UtilsDownloadFromHTTP {
158158
}
159159

160160
class func extractDBFiles(from zipFile: URL, completion: @escaping ([URL], Error?) -> Void) {
161-
DispatchQueue.global().async {
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)