Skip to content

Commit b990969

Browse files
committed
read receipt: do not forcibly unwrap an optional when app groups are not well configured
1 parent 7a64e6f commit b990969

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Sources/Swift/Display Receipt/DisplayReceiptCacheHelper.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ internal struct DisplayReceiptCacheHelper {
2828

2929
static func sharedDirectory() throws -> URL {
3030
do {
31-
let sharedDir = FileManager
32-
.default
33-
.containerURL(forSecurityApplicationGroupIdentifier: try self.sharedGroupId())!
34-
.appendingPathComponent(Consts.receiptCacheDirectory)
31+
guard let sharedDir = FileManager
32+
.default
33+
.containerURL(forSecurityApplicationGroupIdentifier: try self.sharedGroupId())?
34+
.appendingPathComponent(Consts.receiptCacheDirectory)
35+
else { throw DisplayReceiptHelperError.appGroupError }
3536

3637
try FileManager.default.createDirectory(at: sharedDir, withIntermediateDirectories: true, attributes: nil)
3738
return sharedDir

Sources/Swift/Display Receipt/DisplayReceiptHelper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public enum DisplayReceiptHelperError: Error, CustomNSError {
9090
case .unpackError:
9191
return "Error when unpacking receipt"
9292
case .appGroupError:
93-
return "Could not get app group folder"
93+
return "Could not get app group folder"
9494
case .unknownError:
9595
return "An unknown error occurred"
9696
}

0 commit comments

Comments
 (0)