Skip to content

Commit 7b3f850

Browse files
Update NCFiles+SyncMetadata.swift
1 parent def7b73 commit 7b3f850

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

iOSClient/Files/NCFiles+SyncMetadata.swift

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ extension NCFiles {
6262
///
6363
/// - Parameter metadatas: The list of `tableMetadata` entries to scan and refresh.
6464
func networkSyncMetadata(metadatas: [tableMetadata]) async {
65-
// Get account for the first metadata, to be safe, it is better to take the account here and not from the session since it can cause problems if you change users in the meantime
66-
guard let account = metadatas.first?.account else {
67-
return
68-
}
6965
// Order by date (descending)
7066
let metadatas = metadatas.sorted {
7167
($0.date as Date) > ($1.date as Date)
@@ -90,7 +86,13 @@ extension NCFiles {
9086
return
9187
}
9288

93-
// Skip error or e2ee
89+
// Get account for the first metadata, to be safe, it is better to take the account here and not from the session
90+
// since it can cause problems if you change users in the meantime.
91+
//
92+
// Read the current folder
93+
guard let account = metadatas.first?.account else {
94+
return
95+
}
9496
let resultsReadFile = await NCNetworking.shared.readFileAsync(serverUrlFileName: serverUrl, account: account) { task in
9597
Task {
9698
await self.networking.networkingTasks.track(identifier: identifier, task: task)
@@ -107,6 +109,10 @@ extension NCFiles {
107109

108110
// Iterate directories and fetch only when ETag changed
109111
for metadata in metadatas {
112+
// user changed
113+
if metadata.account != session.account {
114+
return
115+
}
110116
if Task.isCancelled {
111117
break
112118
}
@@ -117,7 +123,7 @@ extension NCFiles {
117123
}
118124
let serverUrl = metadata.serverUrlFileName
119125

120-
let resultsReadFolder = await NCNetworking.shared.readFolderAsync(serverUrl: serverUrl, account: account) { task in
126+
let resultsReadFolder = await NCNetworking.shared.readFolderAsync(serverUrl: serverUrl, account: metadata.account) { task in
121127
Task {
122128
await self.networking.networkingTasks.track(identifier: identifier, task: task)
123129
}

0 commit comments

Comments
 (0)