mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
[AltStore] Tracks background refresh attempts for debugging
This commit is contained in:
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