Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/ios.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarino Faggiana <marino@marinofaggiana.com>2022-11-04 18:27:50 +0300
committerMarino Faggiana <marino@marinofaggiana.com>2022-11-04 18:27:50 +0300
commitaea48d58187c5859f07bdc3f21879fae4d355cd8 (patch)
treed5b176f54d8101f34268828030b789c0b9d1ccff
parentc884a2890a36e5c4441221809f7d64fd178f3a54 (diff)
added observeTableMetadata
Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
-rw-r--r--iOSClient/AppDelegate.swift6
-rw-r--r--iOSClient/Networking/NCNetworkingProcessUpload.swift33
2 files changed, 29 insertions, 10 deletions
diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift
index a508b9fc9..6c4194f88 100644
--- a/iOSClient/AppDelegate.swift
+++ b/iOSClient/AppDelegate.swift
@@ -189,8 +189,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
NKCommon.shared.writeLog("[INFO] Application did become active")
- // START OBSERVE UPLOAD PROCESS
+ // START OBSERVE/TIMER UPLOAD PROCESS
NCNetworkingProcessUpload.shared.observeTableMetadata()
+ NCNetworkingProcessUpload.shared.startTimer()
self.deletePasswordSession = false
@@ -243,8 +244,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
NKCommon.shared.writeLog("[INFO] Application will resign active")
- // STOP OBSERVE UPLOAD PROCESS
+ // STOP OBSERVE/TIMER UPLOAD PROCESS
NCNetworkingProcessUpload.shared.invalidateObserveTableMetadata()
+ NCNetworkingProcessUpload.shared.stopTimer()
if CCUtility.getPrivacyScreenEnabled() {
// Privacy
diff --git a/iOSClient/Networking/NCNetworkingProcessUpload.swift b/iOSClient/Networking/NCNetworkingProcessUpload.swift
index ca9f33a25..b9884afa3 100644
--- a/iOSClient/Networking/NCNetworkingProcessUpload.swift
+++ b/iOSClient/Networking/NCNetworkingProcessUpload.swift
@@ -34,6 +34,7 @@ class NCNetworkingProcessUpload: NSObject {
}()
private var notificationToken: NotificationToken?
+ private var timerProcess: Timer?
func observeTableMetadata() {
let realm = try! Realm()
@@ -58,6 +59,20 @@ class NCNetworkingProcessUpload: NSObject {
func invalidateObserveTableMetadata() {
notificationToken?.invalidate()
+ notificationToken = nil
+ }
+
+ func startTimer() {
+ DispatchQueue.main.async {
+ self.timerProcess?.invalidate()
+ self.timerProcess = Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(self.processTimer), userInfo: nil, repeats: true)
+ }
+ }
+
+ func stopTimer() {
+ DispatchQueue.main.async {
+ self.timerProcess?.invalidate()
+ }
}
func start(completition: @escaping (_ items: Int) -> Void) {
@@ -150,14 +165,6 @@ class NCNetworkingProcessUpload: NSObject {
}
}
- // No upload available ? --> Retry Upload in Error
- if counterUpload == 0 {
- let metadatas = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "status == %d", NCGlobal.shared.metadataStatusUploadError))
- for metadata in metadatas {
- NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: NCNetworking.shared.sessionIdentifierBackground, sessionError: "", sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusWaitUpload)
- }
- }
-
// verify delete Asset Local Identifiers in auto upload (DELETE Photos album)
if applicationState == .active && counterUpload == 0 && !isPasscodePresented {
self.deleteAssetLocalIdentifiers(account: account.account) {
@@ -170,6 +177,16 @@ class NCNetworkingProcessUpload: NSObject {
}
}
+ @objc private func processTimer() {
+ if notificationToken != nil {
+ // No upload available ? --> Retry Upload in Error
+ let metadatas = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "status == %d", NCGlobal.shared.metadataStatusUploadError))
+ for metadata in metadatas {
+ NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: NCNetworking.shared.sessionIdentifierBackground, sessionError: "", sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusWaitUpload)
+ }
+ }
+ }
+
private func deleteAssetLocalIdentifiers(account: String, completition: @escaping () -> Void) {
DispatchQueue.main.async {