Skip to content

Commit

Permalink
chore: SonarCloud feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-coye committed Feb 6, 2024
1 parent 273dd1f commit 0f8c9a0
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions kDriveCore/Services/BackgroundTasksService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public protocol BackgroundTasksServiceable {
}

struct BackgroundTasksService: BackgroundTasksServiceable {
private static let activityShouldTerminateMessage = "Notified activity should terminate"

@LazyInjectService private var scheduler: BGTaskScheduler
@LazyInjectService private var accountManager: AccountManageable
@LazyInjectService private var uploadQueue: UploadQueue
Expand Down Expand Up @@ -92,7 +94,7 @@ struct BackgroundTasksService: BackgroundTasksServiceable {
Log.backgroundTaskScheduling("handleBackgroundRefresh")
// User installed the app but never logged in
if expiringActivity.shouldTerminate || accountManager.accounts.isEmpty {
Log.backgroundTaskScheduling("Notified activity should terminate", level: .error)
Log.backgroundTaskScheduling(Self.activityShouldTerminateMessage, level: .error)
completion(false)
expiringActivity.endAll()
return
Expand All @@ -101,8 +103,8 @@ struct BackgroundTasksService: BackgroundTasksServiceable {
Log.backgroundTaskScheduling("Enqueue new pictures")
photoUploader.scheduleNewPicturesForUpload()

guard expiringActivity.shouldTerminate == false else {
Log.backgroundTaskScheduling("Notified activity should terminate", level: .error)
guard !expiringActivity.shouldTerminate else {
Log.backgroundTaskScheduling(Self.activityShouldTerminateMessage, level: .error)
completion(false)
expiringActivity.endAll()
return
Expand All @@ -111,8 +113,8 @@ struct BackgroundTasksService: BackgroundTasksServiceable {
Log.backgroundTaskScheduling("Clean errors for all uploads")
uploadQueue.cleanNetworkAndLocalErrorsForAllOperations()

guard expiringActivity.shouldTerminate == false else {
Log.backgroundTaskScheduling("Notified activity should terminate", level: .error)
guard !expiringActivity.shouldTerminate else {
Log.backgroundTaskScheduling(Self.activityShouldTerminateMessage, level: .error)
completion(false)
expiringActivity.endAll()
return
Expand All @@ -121,8 +123,8 @@ struct BackgroundTasksService: BackgroundTasksServiceable {
Log.backgroundTaskScheduling("Reload operations in queue")
uploadQueue.rebuildUploadQueueFromObjectsInRealm()

guard expiringActivity.shouldTerminate == false else {
Log.backgroundTaskScheduling("Notified activity should terminate", level: .error)
guard !expiringActivity.shouldTerminate else {
Log.backgroundTaskScheduling(Self.activityShouldTerminateMessage, level: .error)
completion(false)
expiringActivity.endAll()
return
Expand Down

0 comments on commit 0f8c9a0

Please sign in to comment.