mirror of https://github.com/oxen-io/session-ios
Additional bug fixes, log tweaks and update checking
• Added a new CheckForAppUpdates job which runs at most once every 24 hours • Updated the job failure logs to include the error that caused the failure • Updated the network instance to use 'single_path_mode' when not executing within the main app • Updated the logger to append extension logs when resuming instead of only during startup • Updated the export logs behaviour to append the previously rotated log data if the latest log file is too short (to ensure we get more useful info when debugging) • Updated to the latest libSession commit to resolve a couple of edge-casespull/981/head
parent
6663bd64c4
commit
cac5542868
@ -1 +1 @@
|
|||||||
Subproject commit 714230c0c8867ac8662603fd6debb5b4c4369ef1
|
Subproject commit 9a867d563266b875144285cd49b07b3aacf7206e
|
@ -0,0 +1,25 @@
|
|||||||
|
// Copyright © 2024 Rangeproof Pty Ltd. All rights reserved.
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import GRDB
|
||||||
|
import SessionUtilitiesKit
|
||||||
|
|
||||||
|
enum _019_ScheduleAppUpdateCheckJob: Migration {
|
||||||
|
static let target: TargetMigrations.Identifier = .messagingKit
|
||||||
|
static let identifier: String = "ScheduleAppUpdateCheckJob" // stringlint:disable
|
||||||
|
static let needsConfigSync: Bool = false
|
||||||
|
static let minExpectedRunDuration: TimeInterval = 0.1
|
||||||
|
static var requirements: [MigrationRequirement] = [.libSessionStateLoaded]
|
||||||
|
static let fetchedTables: [(TableRecord & FetchableRecord).Type] = []
|
||||||
|
static let createdOrAlteredTables: [(TableRecord & FetchableRecord).Type] = []
|
||||||
|
static let droppedTables: [(TableRecord & FetchableRecord).Type] = []
|
||||||
|
|
||||||
|
static func migrate(_ db: GRDB.Database) throws {
|
||||||
|
_ = try Job(
|
||||||
|
variant: .checkForAppUpdates,
|
||||||
|
behaviour: .recurring
|
||||||
|
).migrationSafeInserted(db)
|
||||||
|
|
||||||
|
Storage.update(progress: 1, for: self, in: target) // In case this is the last migration
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
// Copyright © 2024 Rangeproof Pty Ltd. All rights reserved.
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Combine
|
||||||
|
import SessionUtilitiesKit
|
||||||
|
import SessionSnodeKit
|
||||||
|
|
||||||
|
public enum CheckForAppUpdatesJob: JobExecutor {
|
||||||
|
public static var maxFailureCount: Int = -1
|
||||||
|
public static var requiresThreadId: Bool = false
|
||||||
|
public static let requiresInteractionId: Bool = false
|
||||||
|
|
||||||
|
public static func run(
|
||||||
|
_ job: Job,
|
||||||
|
queue: DispatchQueue,
|
||||||
|
success: @escaping (Job, Bool, Dependencies) -> (),
|
||||||
|
failure: @escaping (Job, Error?, Bool, Dependencies) -> (),
|
||||||
|
deferred: @escaping (Job, Dependencies) -> (),
|
||||||
|
using dependencies: Dependencies
|
||||||
|
) {
|
||||||
|
dependencies.storage
|
||||||
|
.readPublisher(using: dependencies) { db -> [UInt8]? in Identity.fetchUserEd25519KeyPair(db)?.secretKey }
|
||||||
|
.subscribe(on: queue)
|
||||||
|
.receive(on: queue)
|
||||||
|
.tryFlatMap { maybeEd25519SecretKey in
|
||||||
|
guard let ed25519SecretKey: [UInt8] = maybeEd25519SecretKey else { throw StorageError.objectNotFound }
|
||||||
|
|
||||||
|
return LibSession.checkClientVersion(
|
||||||
|
ed25519SecretKey: ed25519SecretKey,
|
||||||
|
using: dependencies
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.sinkUntilComplete(
|
||||||
|
receiveCompletion: { _ in
|
||||||
|
var updatedJob: Job = job.with(
|
||||||
|
failureCount: 0,
|
||||||
|
nextRunTimestamp: (dependencies.dateNow.timeIntervalSince1970 + (24 * 60 * 60))
|
||||||
|
)
|
||||||
|
|
||||||
|
dependencies.storage.write(using: dependencies) { db in
|
||||||
|
try updatedJob.save(db)
|
||||||
|
}
|
||||||
|
|
||||||
|
success(updatedJob, false, dependencies)
|
||||||
|
},
|
||||||
|
receiveValue: { _, versionInfo in
|
||||||
|
switch versionInfo.prerelease {
|
||||||
|
case .none: Log.info("[CheckForAppUpdatesJob] Latest version: \(versionInfo.version)")
|
||||||
|
case .some(let prerelease):
|
||||||
|
Log.info("[CheckForAppUpdatesJob] Latest version: \(versionInfo.version), pre-release version: \(prerelease.version)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue