Skip to content

Commit

Permalink
fix upload (replace)
Browse files Browse the repository at this point in the history
Signed-off-by: Marino Faggiana <[email protected]>
  • Loading branch information
marinofaggiana committed Jun 5, 2024
1 parent 08c2dd7 commit 622e88a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
12 changes: 12 additions & 0 deletions iOSClient/Data/NCManageDatabase+Metadata+Session.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,16 @@ extension NCManageDatabase {
return nil
}
}

func getMetadata(from url: URL?, sessionTaskIdentifier: Int) -> tableMetadata? {
guard let url,
var serverUrl = url.deletingLastPathComponent().absoluteString.removingPercentEncoding
else { return nil }
let fileName = url.lastPathComponent

if serverUrl.hasSuffix("/") {
serverUrl = String(serverUrl.dropLast())
}
return NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "serverUrl == %@ AND fileName == %@ AND sessionTaskIdentifier == %d", serverUrl, fileName, sessionTaskIdentifier))
}
}
12 changes: 0 additions & 12 deletions iOSClient/Data/NCManageDatabase+Metadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1147,16 +1147,4 @@ extension NCManageDatabase {

return nil
}

func getMetadata(from url: URL?) -> tableMetadata? {
guard let url,
var serverUrl = url.deletingLastPathComponent().absoluteString.removingPercentEncoding
else { return nil }
let fileName = url.lastPathComponent

if serverUrl.hasSuffix("/") {
serverUrl = String(serverUrl.dropLast())
}
return NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "serverUrl == %@ AND fileName == %@", serverUrl, fileName))
}
}
2 changes: 1 addition & 1 deletion iOSClient/Networking/NCNetworking+Download.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ extension NCNetworking {
DispatchQueue.global().async {

guard let url = task.currentRequest?.url,
let metadata = NCManageDatabase.shared.getMetadata(from: url) else { return }
let metadata = NCManageDatabase.shared.getMetadata(from: url, sessionTaskIdentifier: task.taskIdentifier) else { return }

self.downloadMetadataInBackground.removeValue(forKey: FileNameServerUrl(fileName: fileName, serverUrl: serverUrl))

Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Networking/NCNetworking+Upload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ extension NCNetworking {
task: URLSessionTask,
error: NKError) {
guard let url = task.currentRequest?.url,
let metadata = NCManageDatabase.shared.getMetadata(from: url) else { return }
let metadata = NCManageDatabase.shared.getMetadata(from: url, sessionTaskIdentifier: task.taskIdentifier) else { return }
uploadComplete(metadata: metadata, ocId: ocId, etag: etag, date: date, size: size, error: error)
}

Expand Down

0 comments on commit 622e88a

Please sign in to comment.