From c2d1b3628e948b52ad636dc0023fb19ae354e4be Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Tue, 14 Jan 2020 18:39:08 -0800 Subject: [PATCH] Adds InstalledApp.team relationship --- .../AltStore.xcdatamodeld/AltStore 2.xcdatamodel/contents | 8 +++++--- AltStore/Model/InstalledApp.swift | 1 + AltStore/Model/Team.swift | 1 + AltStore/Operations/InstallAppOperation.swift | 5 +++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/AltStore/Model/AltStore.xcdatamodeld/AltStore 2.xcdatamodel/contents b/AltStore/Model/AltStore.xcdatamodeld/AltStore 2.xcdatamodel/contents index 6e401c9e..1f95d2e6 100644 --- a/AltStore/Model/AltStore.xcdatamodeld/AltStore 2.xcdatamodel/contents +++ b/AltStore/Model/AltStore.xcdatamodeld/AltStore 2.xcdatamodel/contents @@ -1,5 +1,5 @@ - + @@ -26,6 +26,7 @@ + @@ -117,6 +118,7 @@ + @@ -126,12 +128,12 @@ - + - + \ No newline at end of file diff --git a/AltStore/Model/InstalledApp.swift b/AltStore/Model/InstalledApp.swift index 4acea713..96e8caca 100644 --- a/AltStore/Model/InstalledApp.swift +++ b/AltStore/Model/InstalledApp.swift @@ -25,6 +25,7 @@ class InstalledApp: NSManagedObject, Fetchable /* Relationships */ @NSManaged var storeApp: StoreApp? + @NSManaged var team: Team? var isSideloaded: Bool { return self.storeApp == nil diff --git a/AltStore/Model/Team.swift b/AltStore/Model/Team.swift index e130fcf0..d8e1ad32 100644 --- a/AltStore/Model/Team.swift +++ b/AltStore/Model/Team.swift @@ -37,6 +37,7 @@ class Team: NSManagedObject, Fetchable /* Relationships */ @NSManaged private(set) var account: Account! + @NSManaged var installedApps: Set var altTeam: ALTTeam? diff --git a/AltStore/Operations/InstallAppOperation.swift b/AltStore/Operations/InstallAppOperation.swift index d9820578..d653888c 100644 --- a/AltStore/Operations/InstallAppOperation.swift +++ b/AltStore/Operations/InstallAppOperation.swift @@ -66,6 +66,11 @@ class InstallAppOperation: ResultOperation installedApp.expirationDate = profile.expirationDate } + if let team = Team.first(satisfying: NSPredicate(format: "%K == %@", #keyPath(Team.isActiveTeam), NSNumber(value: true)), in: backgroundContext) + { + installedApp.team = team + } + // Temporary directory and resigned .ipa no longer needed, so delete them now to ensure AltStore doesn't quit before we get the chance to. self.cleanUp()