Skip to content

Commit

Permalink
Scan - Improvements (#2610)
Browse files Browse the repository at this point in the history
* Update NCUploadScanDocument.swift
* Update NCScan.swift
* Update NCNetworking.swift
* Update NCManageDatabase+Metadata.swift
* Update CCAdvanced.m
* Update NCNetworkingCheckRemoteUser.swift
* fix quota, verify quota free before error 507

Signed-off-by: Marino Faggiana <[email protected]>

---------

Signed-off-by: Marino Faggiana <[email protected]>
  • Loading branch information
marinofaggiana authored Sep 29, 2023
1 parent 74cf6bd commit 5b1c49a
Show file tree
Hide file tree
Showing 16 changed files with 229 additions and 272 deletions.
9 changes: 3 additions & 6 deletions iOSClient/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
NextcloudKit.shared.nkCommonInstance.writeLog("[ERROR] Create share accounts \(error.localizedDescription)")
}

NCOperationQueue.shared.cancelAllQueue()
NCNetworking.shared.cancelAllDownloadTransfer()
NextcloudKit.shared.sessionManager.cancelAllRequests()
NCNetworking.shared.cancelSessions(inBackground: false)

presentPasscode { }

Expand All @@ -269,7 +267,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
// L'applicazione terminerà
func applicationWillTerminate(_ application: UIApplication) {

NCNetworking.shared.cancelAllDownloadTransfer()
NCNetworking.shared.cancelSessions(inBackground: false)

if UIApplication.shared.backgroundRefreshStatus == .available {

Expand Down Expand Up @@ -560,8 +558,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD

guard let tableAccount = NCManageDatabase.shared.setAccountActive(account) else { return }

NCOperationQueue.shared.cancelAllQueue()
NCNetworking.shared.cancelAllTask()
NCNetworking.shared.cancelSessions(inBackground: false)

self.account = tableAccount.account
self.urlBase = tableAccount.urlBase
Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Color/NCColorPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class NCColorPicker: UIViewController {
let serverUrl = metadata.serverUrl + "/" + metadata.fileName
if NCManageDatabase.shared.setDirectory(serverUrl: serverUrl, colorFolder: hexColor, account: metadata.account) != nil {
self.dismiss(animated: true)
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource, userInfo: ["serverUrl": metadata.serverUrl])
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource)
}
}
self.dismiss(animated: true)
Expand Down
45 changes: 23 additions & 22 deletions iOSClient/Data/NCManageDatabase+Metadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -631,28 +631,29 @@ extension NCManageDatabase {
do {
let realm = try Realm()
try realm.write {
let result = realm.objects(tableMetadata.self).filter("ocId == %@", ocId).first
if let newFileName = newFileName {
result?.fileName = newFileName
result?.fileNameView = newFileName
}
if let session = session {
result?.session = session
}
if let sessionError = sessionError {
result?.sessionError = sessionError
}
if let sessionSelector = sessionSelector {
result?.sessionSelector = sessionSelector
}
if let sessionTaskIdentifier = sessionTaskIdentifier {
result?.sessionTaskIdentifier = sessionTaskIdentifier
}
if let status = status {
result?.status = status
}
if let etag = etag {
result?.etag = etag
if let result = realm.objects(tableMetadata.self).filter("ocId == %@", ocId).first {
if let newFileName = newFileName {
result.fileName = newFileName
result.fileNameView = newFileName
}
if let session = session {
result.session = session
}
if let sessionError = sessionError {
result.sessionError = sessionError
}
if let sessionSelector = sessionSelector {
result.sessionSelector = sessionSelector
}
if let sessionTaskIdentifier = sessionTaskIdentifier {
result.sessionTaskIdentifier = sessionTaskIdentifier
}
if let status = status {
result.status = status
}
if let etag = etag {
result.etag = etag
}
}
}
} catch let error {
Expand Down
8 changes: 6 additions & 2 deletions iOSClient/Main/Collection Common/NCCollectionViewCommon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
if namedButtonMore == NCGlobal.shared.buttonMoreMore || namedButtonMore == NCGlobal.shared.buttonMoreLock {
toggleMenu(metadata: metadata, indexPath: indexPath, imageIcon: image)
} else if namedButtonMore == NCGlobal.shared.buttonMoreStop {
NCNetworking.shared.cancelTransferMetadata(metadata) { }
Task {
await NCNetworking.shared.cancel(metadata: metadata)
}
}
}

Expand All @@ -826,7 +828,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
func tapButtonTransfer(_ sender: Any) {
if let ocId = NCNetworking.shared.transferInForegorund?.ocId,
let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
NCNetworking.shared.cancelTransferMetadata(metadata) { }
Task {
await NCNetworking.shared.cancel(metadata: metadata)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Menu/NCSortMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,6 @@ class NCSortMenu: NSObject {

self.sortButton?.setTitle(NSLocalizedString(layoutForView.titleButtonHeader, comment: ""), for: .normal)
NCManageDatabase.shared.setLayoutForView(layoutForView: layoutForView)
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource, userInfo: ["serverUrl": self.serverUrl])
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource)
}
}
7 changes: 4 additions & 3 deletions iOSClient/NCGlobal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,10 @@ class NCGlobal: NSObject {
@objc let errorUnauthorized401: Int = 401
@objc let errorForbidden: Int = 403
@objc let errorResourceNotFound: Int = 404
@objc let errordMethodNotSupported: Int = 405
@objc let errorMethodNotSupported: Int = 405
@objc let errorConflict: Int = 409
@objc let errorPreconditionFailed: Int = 412
@objc let errorQuota: Int = 507
@objc let errorUnauthorized997: Int = 997
@objc let errorConnectionLost: Int = -1005
@objc let errorNetworkNotAvailable: Int = -1009
Expand Down Expand Up @@ -348,8 +349,8 @@ class NCGlobal: NSObject {
let notificationCenterUpdateBadgeNumber = "updateBadgeNumber" // userInfo: counter
let notificationCenterReloadAvatar = "reloadAvatar"

@objc let notificationCenterReloadDataSource = "reloadDataSource" // userInfo: serverUrl?
let notificationCenterReloadDataSourceNetwork = "reloadDataSourceNetwork" // userInfo: serverUrl?
@objc let notificationCenterReloadDataSource = "reloadDataSource"
let notificationCenterReloadDataSourceNetwork = "reloadDataSourceNetwork"
let notificationCenterReloadDataSourceNetworkForced = "reloadDataSourceNetworkForced"

let notificationCenterChangeStatusFolderE2EE = "changeStatusFolderE2EE" // userInfo: serverUrl
Expand Down
Loading

0 comments on commit 5b1c49a

Please sign in to comment.