session-ios/SignalUtilitiesKit/Database/Storage/Storage+Jobs.swift

31 lines
1.1 KiB
Swift
Raw Normal View History

2020-11-19 05:24:09 +01:00
extension Storage {
public func persist(_ job: Job, using transaction: Any) {
(transaction as! YapDatabaseReadWriteTransaction).setObject(job, forKey: job.id!, inCollection: type(of: job).collection)
}
public func markJobAsSucceeded(_ job: Job, using transaction: Any) {
(transaction as! YapDatabaseReadWriteTransaction).removeObject(forKey: job.id!, inCollection: type(of: job).collection)
}
public func markJobAsFailed(_ job: Job, using transaction: Any) {
(transaction as! YapDatabaseReadWriteTransaction).removeObject(forKey: job.id!, inCollection: type(of: job).collection)
}
public func getAllPendingJobs(of type: Job.Type) -> [Job] {
var result: [Job] = []
Storage.read { transaction in
transaction.enumerateRows(inCollection: type.collection) { _, object, _, _ in
guard let job = object as? Job else { return }
result.append(job)
}
}
return result
}
2020-11-23 06:05:39 +01:00
public func getAttachmentUploadJob(for attachmentID: String) -> AttachmentUploadJob? {
return nil // TODO: Implement
}
2020-11-19 05:24:09 +01:00
}