Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix only 1 file uploading when selecting multiple #2537

Merged

Conversation

mpivchev
Copy link
Collaborator

@mpivchev mpivchev commented Jul 17, 2023

This closes #2532

  • Fixes multiple files not uploading
  • Also fixes conflict window, where before it would only show 1 conflict and ignore the rest. Now it shows multiple conflicts (if any), and processes all of them, while files that don't have a conflict continue being uploaded normally.

Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>

for urlIn in urls {
let ocId = NSUUID().uuidString
Copy link
Collaborator Author

@mpivchev mpivchev Jul 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used the same id for all files, which caused them to get overwritten in Realm. Now each file has a different ID.

Comment on lines +177 to 196
if let _ = NCManageDatabase.shared.getMetadataConflict(account: appDelegate.account, serverUrl: serverUrl, fileNameView: fileName) {
metadatasInConflict.append(metadataForUpload)
} else {
metadatas.append(metadataForUpload)
}
}

if let conflict = UIStoryboard(name: "NCCreateFormUploadConflict", bundle: nil).instantiateInitialViewController() as? NCCreateFormUploadConflict {
NCNetworkingProcessUpload.shared.createProcessUploads(metadatas: metadatas, completion: { _ in })

conflict.delegate = appDelegate
conflict.serverUrl = serverUrl
conflict.metadatasUploadInConflict = [metadataForUpload]
if !metadatasInConflict.isEmpty {
if let conflict = UIStoryboard(name: "NCCreateFormUploadConflict", bundle: nil).instantiateInitialViewController() as? NCCreateFormUploadConflict {

appDelegate.window?.rootViewController?.present(conflict, animated: true, completion: nil)
}
conflict.delegate = appDelegate
conflict.serverUrl = serverUrl
conflict.metadatasUploadInConflict = metadatasInConflict

} else {
NCNetworkingProcessUpload.shared.createProcessUploads(metadatas: [metadataForUpload], completion: { _ in })
appDelegate.window?.rootViewController?.present(conflict, animated: true, completion: nil)
}
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Files in conflict will go through NCCreateFormUploadConflict, while the rest would continue uploading normally.

@mpivchev
Copy link
Collaborator Author

@marinofaggiana It would be great if you can test this manually, in case i missed anything. I will also try to make some unit/integration tests for this.

@mpivchev mpivchev linked an issue Jul 17, 2023 that may be closed by this pull request
@mpivchev mpivchev changed the title 2532 upload file selecting multiple files only 1 file uploads Fix only 1 file uploading when selecting multiple Jul 17, 2023
@codecov
Copy link

codecov bot commented Jul 17, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (2d0c8ba) 9.19% compared to head (373a559) 9.20%.

❗ Current head 373a559 differs from pull request most recent head 040be9c. Consider uploading reports for the commit 040be9c to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           develop   #2537   +/-   ##
=======================================
  Coverage     9.19%   9.20%           
=======================================
  Files          185     185           
  Lines        26124   26129    +5     
  Branches      9775    9775           
=======================================
+ Hits          2401    2404    +3     
- Misses       23510   23513    +3     
+ Partials       213     212    -1     
Impacted Files Coverage Δ
iOSClient/Data/NCManageDatabase+Metadata.swift 20.20% <0.00%> (-0.41%) ⬇️
iOSClient/Main/NCPickerViewController.swift 0.00% <0.00%> (ø)

... and 8 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@marinofaggiana
Copy link
Member

Please rebase before PR (the database version is different and this removed the current DB in the emulator, so I must reinsert the accounts etc)

…upload-file-selecting-multiple-files-only-1-file-uploads
@mpivchev
Copy link
Collaborator Author

@marinofaggiana done


let fileName = urlIn.lastPathComponent
let toPath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName)!
let urlOut = URL(fileURLWithPath: toPath)
let serverUrl = appDelegate.activeServerUrl

guard let url = self.copySecurityScopedResource(url: urlIn, urlOut: urlOut) else { continue }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix lint here, url is not used.

Copy link
Member

@marinofaggiana marinofaggiana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works.

Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
@mpivchev mpivchev merged commit ea40c6d into develop Jul 17, 2023
4 checks passed
@delete-merged-branch delete-merged-branch bot deleted the 2532-upload-file-selecting-multiple-files-only-1-file-uploads branch July 17, 2023 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upload file -> selecting multiple files -> only 1 file uploads
2 participants