mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 14:53:25 +01:00
[AltStore] Tracks background refresh attempts for debugging
This commit is contained in:
@@ -56,6 +56,17 @@
|
||||
</uniquenessConstraint>
|
||||
</uniquenessConstraints>
|
||||
</entity>
|
||||
<entity name="RefreshAttempt" representedClassName="RefreshAttempt" syncable="YES">
|
||||
<attribute name="date" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
|
||||
<attribute name="errorDescription" optional="YES" attributeType="String" syncable="YES"/>
|
||||
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
||||
<attribute name="isSuccess" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
|
||||
<uniquenessConstraints>
|
||||
<uniquenessConstraint>
|
||||
<constraint value="identifier"/>
|
||||
</uniquenessConstraint>
|
||||
</uniquenessConstraints>
|
||||
</entity>
|
||||
<entity name="Source" representedClassName="Source" syncable="YES">
|
||||
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
||||
<attribute name="name" attributeType="String" syncable="YES"/>
|
||||
@@ -84,7 +95,8 @@
|
||||
<element name="App" positionX="-63" positionY="-18" width="128" height="300"/>
|
||||
<element name="AppPermission" positionX="-45" positionY="90" width="128" height="90"/>
|
||||
<element name="InstalledApp" positionX="-63" positionY="0" width="128" height="150"/>
|
||||
<element name="Team" positionX="-45" positionY="81" width="128" height="120"/>
|
||||
<element name="Source" positionX="-45" positionY="99" width="128" height="105"/>
|
||||
<element name="Team" positionX="-45" positionY="81" width="128" height="120"/>
|
||||
<element name="RefreshAttempt" positionX="-45" positionY="117" width="128" height="105"/>
|
||||
</elements>
|
||||
</model>
|
||||
51
AltStore/Model/RefreshAttempt.swift
Normal file
51
AltStore/Model/RefreshAttempt.swift
Normal file
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// RefreshAttempt.swift
|
||||
// AltStore
|
||||
//
|
||||
// Created by Riley Testut on 7/31/19.
|
||||
// Copyright © 2019 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import CoreData
|
||||
|
||||
@objc(RefreshAttempt)
|
||||
class RefreshAttempt: NSManagedObject, Fetchable
|
||||
{
|
||||
@NSManaged var identifier: String
|
||||
@NSManaged var date: Date
|
||||
|
||||
@NSManaged var isSuccess: Bool
|
||||
@NSManaged var errorDescription: String?
|
||||
|
||||
private override init(entity: NSEntityDescription, insertInto context: NSManagedObjectContext?)
|
||||
{
|
||||
super.init(entity: entity, insertInto: context)
|
||||
}
|
||||
|
||||
init<T>(identifier: String, result: Result<T, Error>, context: NSManagedObjectContext)
|
||||
{
|
||||
super.init(entity: RefreshAttempt.entity(), insertInto: context)
|
||||
|
||||
self.identifier = identifier
|
||||
self.date = Date()
|
||||
|
||||
switch result
|
||||
{
|
||||
case .success:
|
||||
self.isSuccess = true
|
||||
self.errorDescription = nil
|
||||
|
||||
case .failure(let error):
|
||||
self.isSuccess = false
|
||||
self.errorDescription = error.localizedDescription
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension RefreshAttempt
|
||||
{
|
||||
@nonobjc class func fetchRequest() -> NSFetchRequest<RefreshAttempt>
|
||||
{
|
||||
return NSFetchRequest<RefreshAttempt>(entityName: "RefreshAttempt")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user