Skip to content

Commit 3f13bd9

Browse files
committed
Merge branch 'develop' of https://github.com/nextcloud/ios into 2471-use-multipartupload-for-uploading-chunks-to-s3-2
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com> # Conflicts: # Nextcloud.xcodeproj/project.pbxproj
2 parents 873ce8e + 8dbf5fc commit 3f13bd9

25 files changed

+384
-215
lines changed

Nextcloud.xcodeproj/project.pbxproj

+7-7
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@
178178
F7148041262EBE4000693E51 /* NCShareExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7148040262EBE4000693E51 /* NCShareExtension.swift */; };
179179
F714804F262ED4F900693E51 /* NCGridCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F78ACD4521903D010088454D /* NCGridCell.xib */; };
180180
F7148054262ED51000693E51 /* NCListCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F78ACD4321903CF20088454D /* NCListCell.xib */; };
181-
F7148059262ED52200693E51 /* NCSectionHeaderMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F78ACD57219048040088454D /* NCSectionHeaderMenu.xib */; };
182181
F714805E262ED52900693E51 /* NCSectionFooter.xib in Resources */ = {isa = PBXBuildFile; fileRef = F78ACD53219047D40088454D /* NCSectionFooter.xib */; };
183182
F7148063262ED66200693E51 /* NCEmptyView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7239876253D86D300257F49 /* NCEmptyView.xib */; };
184183
F717402D24F699A5000C87D5 /* NCFavorite.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F717402B24F699A5000C87D5 /* NCFavorite.storyboard */; };
@@ -477,7 +476,6 @@
477476
F78ACD4B21903F850088454D /* NCTrashListCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F78ACD4921903F850088454D /* NCTrashListCell.xib */; };
478477
F78ACD52219046DC0088454D /* NCSectionHeaderMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78ACD51219046DC0088454D /* NCSectionHeaderMenu.swift */; };
479478
F78ACD54219047D40088454D /* NCSectionFooter.xib in Resources */ = {isa = PBXBuildFile; fileRef = F78ACD53219047D40088454D /* NCSectionFooter.xib */; };
480-
F78ACD58219048040088454D /* NCSectionHeaderMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F78ACD57219048040088454D /* NCSectionHeaderMenu.xib */; };
481479
F78C6FDE296D677300C952C3 /* NCContextMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78C6FDD296D677300C952C3 /* NCContextMenu.swift */; };
482480
F78E2D6529AF02DB0024D4F3 /* Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78E2D6429AF02DB0024D4F3 /* Database.swift */; };
483481
F78E2D6629AF02DB0024D4F3 /* Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78E2D6429AF02DB0024D4F3 /* Database.swift */; };
@@ -547,6 +545,8 @@
547545
F7AE00F5230D5F9E007ACF8A /* NCLoginWeb.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7AE00F4230D5F9E007ACF8A /* NCLoginWeb.swift */; };
548546
F7AE00F8230E81CB007ACF8A /* NCBrowserWeb.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7AE00F7230E81CB007ACF8A /* NCBrowserWeb.swift */; };
549547
F7AE00FA230E81EB007ACF8A /* NCBrowserWeb.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7AE00F9230E81EB007ACF8A /* NCBrowserWeb.storyboard */; };
548+
F7B398422A6A91D5007538D6 /* NCSectionHeaderMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7B398412A6A91D5007538D6 /* NCSectionHeaderMenu.xib */; };
549+
F7B398432A6A91D5007538D6 /* NCSectionHeaderMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7B398412A6A91D5007538D6 /* NCSectionHeaderMenu.xib */; };
550550
F7B6B70427C4E7FA00A7F6EB /* NCScan+CollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7B6B70327C4E7FA00A7F6EB /* NCScan+CollectionView.swift */; };
551551
F7B7504B2397D38F004E13EC /* UIImage+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7B7504A2397D38E004E13EC /* UIImage+Extension.swift */; };
552552
F7B8B83025681C3400967775 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = F7B8B82F25681C3400967775 /* GoogleService-Info.plist */; };
@@ -1102,7 +1102,6 @@
11021102
F78ACD4921903F850088454D /* NCTrashListCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NCTrashListCell.xib; sourceTree = "<group>"; };
11031103
F78ACD51219046DC0088454D /* NCSectionHeaderMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCSectionHeaderMenu.swift; sourceTree = "<group>"; };
11041104
F78ACD53219047D40088454D /* NCSectionFooter.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NCSectionFooter.xib; sourceTree = "<group>"; };
1105-
F78ACD57219048040088454D /* NCSectionHeaderMenu.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NCSectionHeaderMenu.xib; sourceTree = "<group>"; };
11061105
F78C6FDD296D677300C952C3 /* NCContextMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCContextMenu.swift; sourceTree = "<group>"; };
11071106
F78D6F461F0B7CB9002F9619 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = "<group>"; };
11081107
F78D6F4D1F0B7CE4002F9619 /* nb-NO */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "nb-NO"; path = "nb-NO.lproj/Localizable.strings"; sourceTree = "<group>"; };
@@ -1191,6 +1190,7 @@
11911190
F7AF7632246BEDFE00B86E3C /* TOPasscodeViewController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = TOPasscodeViewController.framework; path = Carthage/Build/iOS/TOPasscodeViewController.framework; sourceTree = "<group>"; };
11921191
F7B1076C25D3CF2800E72DE2 /* BackgroundTasks.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BackgroundTasks.framework; path = System/Library/Frameworks/BackgroundTasks.framework; sourceTree = SDKROOT; };
11931192
F7B1A7761EBB3C8000BFB6D1 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = "<group>"; };
1193+
F7B398412A6A91D5007538D6 /* NCSectionHeaderMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NCSectionHeaderMenu.xib; sourceTree = "<group>"; };
11941194
F7B6B70327C4E7FA00A7F6EB /* NCScan+CollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCScan+CollectionView.swift"; sourceTree = "<group>"; };
11951195
F7B7504A2397D38E004E13EC /* UIImage+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImage+Extension.swift"; sourceTree = "<group>"; };
11961196
F7B8B82F25681C3400967775 /* GoogleService-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "GoogleService-Info.plist"; sourceTree = SOURCE_ROOT; };
@@ -1964,7 +1964,7 @@
19641964
children = (
19651965
F78ACD53219047D40088454D /* NCSectionFooter.xib */,
19661966
F7FF2CB02842159500EBB7A1 /* NCSectionHeader.xib */,
1967-
F78ACD57219048040088454D /* NCSectionHeaderMenu.xib */,
1967+
F7B398412A6A91D5007538D6 /* NCSectionHeaderMenu.xib */,
19681968
F78ACD51219046DC0088454D /* NCSectionHeaderMenu.swift */,
19691969
);
19701970
path = "Section Header Footer";
@@ -3063,11 +3063,11 @@
30633063
isa = PBXResourcesBuildPhase;
30643064
buildActionMask = 2147483647;
30653065
files = (
3066-
F7148059262ED52200693E51 /* NCSectionHeaderMenu.xib in Resources */,
30673066
F714803B262EBE3900693E51 /* MainInterface.storyboard in Resources */,
30683067
F7148054262ED51000693E51 /* NCListCell.xib in Resources */,
30693068
F7D57C8626317BDA00DE301D /* NCAccountRequest.storyboard in Resources */,
30703069
AF22B209277B4E4C00DAB0CC /* NCCreateFormUploadConflictCell.xib in Resources */,
3070+
F7B398432A6A91D5007538D6 /* NCSectionHeaderMenu.xib in Resources */,
30713071
F7148063262ED66200693E51 /* NCEmptyView.xib in Resources */,
30723072
AF22B207277B4E4C00DAB0CC /* NCCreateFormUploadConflict.storyboard in Resources */,
30733073
F7145A231D12E3B700CAFEEC /* Localizable.strings in Resources */,
@@ -3179,7 +3179,7 @@
31793179
F73CB3B222E072A000AD728E /* NCShareHeaderView.xib in Resources */,
31803180
F7AE00FA230E81EB007ACF8A /* NCBrowserWeb.storyboard in Resources */,
31813181
F7EDE514262DC2CD00414FE6 /* NCSelectCommandViewSelect+CreateFolder.xib in Resources */,
3182-
F78ACD58219048040088454D /* NCSectionHeaderMenu.xib in Resources */,
3182+
F7B398422A6A91D5007538D6 /* NCSectionHeaderMenu.xib in Resources */,
31833183
F7501C322212E57500FB1415 /* NCMedia.storyboard in Resources */,
31843184
F74DE14425135B6800917068 /* NCTransfers.storyboard in Resources */,
31853185
F77910A525DD517B00CEDB9E /* Settings.bundle in Resources */,
@@ -4941,7 +4941,7 @@
49414941
isa = XCRemoteSwiftPackageReference;
49424942
repositoryURL = "https://github.com/nextcloud/NextcloudKit";
49434943
requirement = {
4944-
branch = "2471-use-multipartupload-for-uploading-chunks-to-s3-2";
4944+
branch = develop;
49454945
kind = branch;
49464946
};
49474947
};

Share/NCShareExtension.swift

+2
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ extension NCShareExtension {
339339
metadata.classFile = results.classFile
340340
// CHUNCK
341341
metadata.chunk = chunckSize != 0 && metadata.size > chunckSize
342+
// E2EE
343+
metadata.e2eEncrypted = metadata.isDirectoryE2EE
342344

343345
hud.textLabel.text = NSLocalizedString("_upload_file_", comment: "") + " \(counterUploaded + 1) " + NSLocalizedString("_of_", comment: "") + " \(filesName.count)"
344346
hud.show(in: self.view)

iOSClient/Data/NCDataSource.swift

+6-84
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class NCDataSource: NSObject {
5151
super.init()
5252

5353
self.metadatas = metadatas.filter({
54-
!NCGlobal.shared.includeHiddenFiles.contains($0.fileNameView)
54+
!(NCGlobal.shared.includeHiddenFiles.contains($0.fileNameView) || $0.isTransferInForeground)
5555
})
5656
self.directory = directory
5757
self.localFiles = NCManageDatabase.shared.getTableLocalFile(account: account)
@@ -218,79 +218,6 @@ class NCDataSource: NSObject {
218218
return indexPaths
219219
}
220220

221-
@discardableResult
222-
func addMetadata(_ metadata: tableMetadata) -> (indexPath: IndexPath?, sameSections: Bool) {
223-
224-
let numberOfSections = self.numberOfSections()
225-
let sectionValue = getSectionValue(metadata: metadata)
226-
227-
// ADD metadatasSource
228-
if let rowIndex = self.metadatas.firstIndex(where: {$0.fileNameView == metadata.fileNameView || $0.ocId == metadata.ocId}) {
229-
self.metadatas[rowIndex] = metadata
230-
} else {
231-
self.metadatas.append(metadata)
232-
}
233-
234-
// ADD metadataForSection
235-
if let sectionIndex = getSectionIndex(sectionValue), let metadataForSection = getMetadataForSection(sectionIndex) {
236-
if let rowIndex = metadataForSection.metadatas.firstIndex(where: {$0.fileNameView == metadata.fileNameView || $0.ocId == metadata.ocId}) {
237-
metadataForSection.metadatas[rowIndex] = metadata
238-
return (IndexPath(row: rowIndex, section: sectionIndex), self.isSameNumbersOfSections(numberOfSections: numberOfSections))
239-
} else {
240-
metadataForSection.metadatas.append(metadata)
241-
metadataForSection.createMetadatas()
242-
if let rowIndex = metadataForSection.metadatas.firstIndex(where: {$0.ocId == metadata.ocId}) {
243-
return (IndexPath(row: rowIndex, section: sectionIndex), self.isSameNumbersOfSections(numberOfSections: numberOfSections))
244-
}
245-
return (nil, self.isSameNumbersOfSections(numberOfSections: numberOfSections))
246-
}
247-
} else {
248-
// NEW section
249-
createSections()
250-
// get IndexPath of new section
251-
if let sectionIndex = getSectionIndex(sectionValue), let metadataForSection = getMetadataForSection(sectionIndex) {
252-
if let rowIndex = metadataForSection.metadatas.firstIndex(where: {$0.fileNameView == metadata.fileNameView || $0.ocId == metadata.ocId}) {
253-
return (IndexPath(row: rowIndex, section: sectionIndex), self.isSameNumbersOfSections(numberOfSections: numberOfSections))
254-
}
255-
}
256-
}
257-
258-
return (nil, self.isSameNumbersOfSections(numberOfSections: numberOfSections))
259-
}
260-
261-
func deleteMetadata(ocId: String) -> (indexPath: IndexPath?, sameSections: Bool) {
262-
263-
let numberOfSections = self.numberOfSections()
264-
var indexPathReturn: IndexPath?
265-
var sectionValue = ""
266-
267-
// DELETE metadataForSection (IMPORTANT FIRST)
268-
let (indexPath, metadataForSection) = self.getIndexPathMetadata(ocId: ocId)
269-
if let indexPath = indexPath, let metadataForSection = metadataForSection, indexPath.row < metadataForSection.metadatas.count {
270-
metadataForSection.metadatas.remove(at: indexPath.row)
271-
if metadataForSection.metadatas.isEmpty {
272-
// REMOVE sectionsValue / metadatasForSection
273-
sectionValue = metadataForSection.sectionValue
274-
if let sectionIndex = getSectionIndex(sectionValue) {
275-
self.sectionsValue.remove(at: sectionIndex)
276-
}
277-
if let index = getIndexMetadatasForSection(sectionValue) {
278-
self.metadatasForSection.remove(at: index)
279-
}
280-
} else {
281-
metadataForSection.createMetadatas()
282-
}
283-
indexPathReturn = indexPath
284-
} else { return (nil, false) }
285-
286-
// DELETE metadatasSource (IMPORTANT LAST)
287-
if let rowIndex = self.metadatas.firstIndex(where: {$0.ocId == ocId}) {
288-
self.metadatas.remove(at: rowIndex)
289-
}
290-
291-
return (indexPathReturn, self.isSameNumbersOfSections(numberOfSections: numberOfSections))
292-
}
293-
294221
@discardableResult
295222
func reloadMetadata(ocId: String, ocIdTemp: String? = nil) -> (indexPath: IndexPath?, sameSections: Bool) {
296223

@@ -328,11 +255,6 @@ class NCDataSource: NSObject {
328255
return (IndexPath(row: rowIndex, section: sectionIndex), metadataForSection)
329256
}
330257

331-
func isSameNumbersOfSections(numberOfSections: Int) -> Bool {
332-
guard !self.metadatasForSection.isEmpty else { return false }
333-
return numberOfSections == self.numberOfSections()
334-
}
335-
336258
func numberOfSections() -> Int {
337259
guard !self.sectionsValue.isEmpty else { return 1 }
338260
return self.sectionsValue.count
@@ -348,11 +270,6 @@ class NCDataSource: NSObject {
348270
return metadataForSection.metadatas[indexPath.row]
349271
}
350272

351-
func getSectionValue(indexPath: IndexPath) -> String {
352-
guard !metadatasForSection.isEmpty, let metadataForSection = self.getMetadataForSection(indexPath.section) else { return ""}
353-
return metadataForSection.sectionValue
354-
}
355-
356273
func getSectionValueLocalization(indexPath: IndexPath) -> String {
357274
guard !metadatasForSection.isEmpty, let metadataForSection = self.getMetadataForSection(indexPath.section) else { return ""}
358275
if let searchResults = self.searchResults, let searchResult = searchResults.filter({ $0.id == metadataForSection.sectionValue}).first {
@@ -378,6 +295,11 @@ class NCDataSource: NSObject {
378295

379296
// MARK: -
380297

298+
internal func isSameNumbersOfSections(numberOfSections: Int) -> Bool {
299+
guard !self.metadatasForSection.isEmpty else { return false }
300+
return numberOfSections == self.numberOfSections()
301+
}
302+
381303
internal func getSectionValue(metadata: tableMetadata) -> String {
382304

383305
switch self.groupByField {

iOSClient/Data/NCManageDatabase+Metadata.swift

+22-3
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,18 @@ extension tableMetadata {
211211
return classFile == NKCommon.TypeClassFile.document.rawValue && editors.contains(NCGlobal.shared.editorText) && ((editors.contains(NCGlobal.shared.editorOnlyoffice) || isRichDocument))
212212
}
213213

214-
var isDownloadUpload: Bool {
214+
var isWaitingTransfer: Bool {
215+
status == NCGlobal.shared.metadataStatusWaitDownload || status == NCGlobal.shared.metadataStatusWaitUpload || status == NCGlobal.shared.metadataStatusUploadError
216+
}
217+
218+
var isInTransfer: Bool {
215219
status == NCGlobal.shared.metadataStatusInDownload || status == NCGlobal.shared.metadataStatusDownloading || status == NCGlobal.shared.metadataStatusInUpload || status == NCGlobal.shared.metadataStatusUploading
216220
}
217221

222+
var isTransferInForeground: Bool {
223+
(status > 0 && (chunk || e2eEncrypted))
224+
}
225+
218226
var isDownload: Bool {
219227
status == NCGlobal.shared.metadataStatusInDownload || status == NCGlobal.shared.metadataStatusDownloading
220228
}
@@ -416,7 +424,6 @@ extension NCManageDatabase {
416424
let fileName = fileName.trimmingCharacters(in: .whitespacesAndNewlines)
417425

418426
metadata.account = account
419-
metadata.chunk = false
420427
metadata.creationDate = Date() as NSDate
421428
metadata.date = Date() as NSDate
422429
metadata.hasPreview = true
@@ -867,9 +874,9 @@ extension NCManageDatabase {
867874

868875
func getMetadataFromOcId(_ ocId: String?) -> tableMetadata? {
869876

877+
guard let ocId else { return nil }
870878
do {
871879
let realm = try Realm()
872-
guard let ocId = ocId else { return nil }
873880
guard let result = realm.objects(tableMetadata.self).filter("ocId == %@", ocId).first else { return nil }
874881
return tableMetadata.init(value: result)
875882
} catch let error as NSError {
@@ -879,6 +886,18 @@ extension NCManageDatabase {
879886
return nil
880887
}
881888

889+
func getTableMetadataFromOcId(_ ocId: String?) -> tableMetadata? {
890+
891+
guard let ocId else { return nil }
892+
do {
893+
let realm = try Realm()
894+
return realm.objects(tableMetadata.self).filter("ocId == %@", ocId).first
895+
} catch let error as NSError {
896+
NextcloudKit.shared.nkCommonInstance.writeLog("Could not access to database: \(error)")
897+
}
898+
return nil
899+
}
900+
882901
func getMetadataFromFileId(_ fileId: String?) -> tableMetadata? {
883902

884903
do {

iOSClient/Files/NCFiles.swift

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class NCFiles: NCCollectionViewCommon {
4040
enableSearchBar = true
4141
headerMenuButtonsView = true
4242
headerRichWorkspaceDisable = false
43+
headerMenuTransferView = true
4344
emptyImage = UIImage(named: "folder")?.image(color: NCBrandColor.shared.brandElement, size: UIScreen.main.bounds.width)
4445
emptyTitle = "_files_no_files_"
4546
emptyDescription = "_no_file_pull_down_"

0 commit comments

Comments
 (0)