@@ -627,6 +627,10 @@ public class MockRemoteInterface: RemoteInterface, @unchecked Sendable {
627627 return nil
628628 }
629629
630+ guard let account = mockedAccounts [ account] else {
631+ return nil
632+ }
633+
630634 let sanitisedPath = sanitisedPath ( remotePath, account: account)
631635
632636 guard sanitisedPath != " / " else {
@@ -666,7 +670,7 @@ public class MockRemoteInterface: RemoteInterface, @unchecked Sendable {
666670
667671 func parentItem( path: String , account: Account ) -> MockRemoteItem ? {
668672 let parentRemotePath = parentPath ( path: path, account: account)
669- return item ( remotePath: parentRemotePath, account: account)
673+ return item ( remotePath: parentRemotePath, account: account. ncKitAccount )
670674 }
671675
672676 func randomIdentifier( ) -> String {
@@ -908,7 +912,7 @@ public class MockRemoteInterface: RemoteInterface, @unchecked Sendable {
908912 return ( account. ncKitAccount, nil , . urlError)
909913 }
910914
911- guard let sourceItem = item ( remotePath: remotePathSource, account: account) else {
915+ guard let sourceItem = item ( remotePath: remotePathSource, account: account. ncKitAccount ) else {
912916 print ( " Could not get item for remote path source \( remotePathSource) " )
913917 return ( account. ncKitAccount, nil , . urlError)
914918 }
@@ -997,9 +1001,9 @@ public class MockRemoteInterface: RemoteInterface, @unchecked Sendable {
9971001 fileNameLocalPath: String ,
9981002 account: String ,
9991003 options: NKRequestOptions ,
1000- requestHandler: @escaping ( _ request: DownloadRequest ) -> Void ,
1001- taskHandler: @Sendable @escaping ( _ task: URLSessionTask ) -> Void ,
1002- progressHandler: @escaping ( _ progress: Progress ) -> Void
1004+ requestHandler: @escaping ( _ request: DownloadRequest ) -> Void = { _ in } ,
1005+ taskHandler: @Sendable @escaping ( _ task: URLSessionTask ) -> Void = { _ in } ,
1006+ progressHandler: @escaping ( _ progress: Progress ) -> Void = { _ in }
10031007 ) async -> (
10041008 account: String ,
10051009 etag: String ? ,
@@ -1017,7 +1021,7 @@ public class MockRemoteInterface: RemoteInterface, @unchecked Sendable {
10171021 return ( account, nil , nil , 0 , nil , nil , . urlError)
10181022 }
10191023
1020- guard let item = item ( remotePath: serverUrlFileName, account: account) else {
1024+ guard let item = item ( remotePath: serverUrlFileName, account: account. ncKitAccount ) else {
10211025 return ( account. ncKitAccount, nil , nil , 0 , nil , nil , . urlError)
10221026 }
10231027
@@ -1034,11 +1038,11 @@ public class MockRemoteInterface: RemoteInterface, @unchecked Sendable {
10341038 }
10351039 } catch {
10361040 print ( " Could not write item data: \( error) " )
1037- return ( account, nil , nil , 0 , nil , nil , . urlError)
1041+ return ( account. ncKitAccount , nil , nil , 0 , nil , nil , . urlError)
10381042 }
10391043
10401044 return (
1041- account,
1045+ account. ncKitAccount ,
10421046 item. versionIdentifier,
10431047 item. creationDate as Date ,
10441048 item. size,
@@ -1073,7 +1077,7 @@ public class MockRemoteInterface: RemoteInterface, @unchecked Sendable {
10731077 // Call the enumerate call handler if it exists
10741078 enumerateCallHandler ? ( remotePath, depth, showHiddenFiles, includeHiddenFiles, requestBody, account, options, taskHandler)
10751079
1076- guard let item = item ( remotePath: remotePath, account: account) else {
1080+ guard let item = item ( remotePath: remotePath, account: account. ncKitAccount ) else {
10771081 print ( " Item at \( remotePath) not found. " )
10781082 return (
10791083 account. ncKitAccount,
@@ -1166,7 +1170,7 @@ public class MockRemoteInterface: RemoteInterface, @unchecked Sendable {
11661170 options _: NKRequestOptions = . init( ) ,
11671171 taskHandler _: @escaping ( URLSessionTask ) -> Void = { _ in }
11681172 ) async -> ( account: String , response: HTTPURLResponse ? , error: NKError ) {
1169- guard let item = item ( remotePath: remotePath, account: account) else {
1173+ guard let item = item ( remotePath: remotePath, account: account. ncKitAccount ) else {
11701174 return ( account. ncKitAccount, nil , . urlError)
11711175 }
11721176
@@ -1185,7 +1189,7 @@ public class MockRemoteInterface: RemoteInterface, @unchecked Sendable {
11851189 }
11861190
11871191 public func lockUnlockFile( serverUrlFileName: String , type _: NKLockType ? , shouldLock: Bool , account: Account , options _: NKRequestOptions , taskHandler _: @escaping ( URLSessionTask ) -> Void ) async throws -> NKLock ? {
1188- guard let item = item ( remotePath: serverUrlFileName, account: account) else {
1192+ guard let item = item ( remotePath: serverUrlFileName, account: account. ncKitAccount ) else {
11891193 throw NKError . urlError
11901194 }
11911195
@@ -1206,8 +1210,11 @@ public class MockRemoteInterface: RemoteInterface, @unchecked Sendable {
12061210 responseData: AFDataResponse < Data > ? ,
12071211 error: NKError
12081212 ) {
1209- guard let rootTrashItem else { return ( account. ncKitAccount, [ ] , nil , . invalidData) }
1210- return ( account. ncKitAccount, rootTrashItem. children. map { $0. toNKTrash ( ) } , nil , . success)
1213+ guard let rootTrashItem else {
1214+ return ( account, [ ] , nil , . invalidData)
1215+ }
1216+
1217+ return ( account, rootTrashItem. children. map { $0. toNKTrash ( ) } , nil , . success)
12111218 }
12121219
12131220 public func restoreFromTrash(
@@ -1254,7 +1261,7 @@ public class MockRemoteInterface: RemoteInterface, @unchecked Sendable {
12541261 return Capabilities ( data: capsData ?? Data ( ) )
12551262 }
12561263
1257- func getUserProfileAsync(
1264+ public func getUserProfileAsync(
12581265 account: String ,
12591266 options: NKRequestOptions ,
12601267 taskHandler: @Sendable @escaping ( _ task: URLSessionTask ) -> Void
@@ -1264,11 +1271,16 @@ public class MockRemoteInterface: RemoteInterface, @unchecked Sendable {
12641271 responseData: AFDataResponse < Data > ? ,
12651272 error: NKError
12661273 ) {
1274+ guard let account = mockedAccounts [ account] else {
1275+ return ( account, nil , nil , . urlError)
1276+ }
1277+
12671278 let profile = NKUserProfile ( )
12681279 profile. address = account. serverUrl
12691280 profile. backend = " mock "
12701281 profile. displayName = account. ncKitAccount
12711282 profile. userId = account. id
1283+
12721284 return ( account. ncKitAccount, profile, nil , . success)
12731285 }
12741286
0 commit comments