Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
[HOTFIX] Fix App Crash when marking episode as complete (#222)
Browse files Browse the repository at this point in the history
* Fix App Crash when marking episode as complete

Also fixed issue where importing backups would create a false error message.

* Log Failed Attempts To Access Security Scoped Resource
  • Loading branch information
uttiya10 authored Jan 27, 2021
1 parent 17893bb commit 381e053
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions NineAnimator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3458,7 +3458,7 @@
CODE_SIGN_ENTITLEMENTS = NineAnimator/NineAnimator.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
CURRENT_PROJECT_VERSION = 5;
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES;
DEVELOPMENT_TEAM = 8WB2V923XT;
INFOPLIST_FILE = NineAnimator/Info.plist;
Expand All @@ -3484,7 +3484,7 @@
CODE_SIGN_ENTITLEMENTS = NineAnimator/NineAnimator.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
CURRENT_PROJECT_VERSION = 5;
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES;
DEVELOPMENT_TEAM = 8WB2V923XT;
INFOPLIST_FILE = NineAnimator/Info.plist;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,10 @@ extension Anilist {
_mutationRequestReferencePool.append(task)
}

internal func cleanupReferencePool() {
func cleanupReferencePool() {
// Remove all resolved promises
_mutationRequestReferencePool.removeAll {
($0 as! NineAnimatorPromise<NSDictionary>).isResolved
($0 as? NineAnimatorPromiseProtocol)?.isResolved == true
}
}
}
12 changes: 8 additions & 4 deletions NineAnimator/Utilities/StatesSerialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ func export(_ configuration: NineAnimatorUser) -> URL? {

func merge(_ configuration: NineAnimatorUser, with fileUrl: URL, policy: NineAnimatorUser.MergePiority) throws {
// Read the contents of the configuration file
guard fileUrl.startAccessingSecurityScopedResource() == true else {
throw NineAnimatorError.unknownError("Failed to access security scoped resource")
// Normally we would check if this function call return true to determine
// if it succeeded, however it creates false negatives, so we only log it.
if fileUrl.startAccessingSecurityScopedResource() == false {
Log.error("Failed to gain access to security scoped resource. Ignoring for now. URL: %@", fileUrl.absoluteString)
}
let serializedConfiguration = try Data(contentsOf: fileUrl)
fileUrl.stopAccessingSecurityScopedResource()
Expand Down Expand Up @@ -111,8 +113,10 @@ func merge(_ configuration: NineAnimatorUser, with fileUrl: URL, policy: NineAni

func replace(_ configuration: NineAnimatorUser, with fileUrl: URL) throws {
// Read the contents of the configuration file
guard fileUrl.startAccessingSecurityScopedResource() == true else {
throw NineAnimatorError.unknownError("Failed to access security scoped resource")
// Normally we would check if this function call return true to determine
// if it succeeded, however it creates false negatives, so we only log it.
if fileUrl.startAccessingSecurityScopedResource() == false {
Log.error("Failed to gain access to security scoped resource. Ignoring for now. URL: %@", fileUrl.absoluteString)
}
let serializedConfiguration = try Data(contentsOf: fileUrl)
fileUrl.stopAccessingSecurityScopedResource()
Expand Down

0 comments on commit 381e053

Please sign in to comment.