Skip to content

Commit c38d042

Browse files
Version 6.1.4 (#3168)
1 parent 53ba879 commit c38d042

File tree

125 files changed

+266
-108
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+266
-108
lines changed

File Provider Extension/FileProviderEnumerator.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
4040
serverUrl = NCUtilityFileSystem().getHomeServer(session: fileProviderData.shared.session)
4141
} else {
4242
if let metadata = providerUtility.getTableMetadataFromItemIdentifier(enumeratedItemIdentifier),
43-
let directorySource = self.database.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl)) {
43+
let directorySource = self.database.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND NOT (status IN %@)", metadata.account, metadata.serverUrl, NCGlobal.shared.metadataStatusHideInFileExtension)) {
4444
serverUrl = directorySource.serverUrl + "/" + metadata.fileName
4545

4646
}
@@ -158,7 +158,7 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
158158
}
159159

160160
func fetchItemsForPage(serverUrl: String, pageNumber: Int, completionHandler: @escaping (_ metadatas: Results<tableMetadata>?) -> Void) {
161-
let predicate = NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.session.account, serverUrl)
161+
let predicate = NSPredicate(format: "account == %@ AND serverUrl == %@ AND NOT (status IN %@)", fileProviderData.shared.session.account, serverUrl, NCGlobal.shared.metadataStatusHideInFileExtension)
162162

163163
if pageNumber == 1 {
164164
NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "1", showHiddenFiles: NCKeychain().showHiddenFiles, account: fileProviderData.shared.session.account) { _, files, _, error in

Nextcloud.xcodeproj/project.pbxproj

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@
148148
F37208C62BAB63F0006B5430 /* LRUCache in Frameworks */ = {isa = PBXBuildFile; productRef = F37208C52BAB63F0006B5430 /* LRUCache */; };
149149
F37208C82BAB63F1006B5430 /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = F37208C72BAB63F1006B5430 /* KeychainAccess */; };
150150
F38F71252B6BBDC300473CDC /* NCCollectionViewCommonSelectTabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = F38F71242B6BBDC300473CDC /* NCCollectionViewCommonSelectTabBar.swift */; };
151+
F39170A92CB82024006127BC /* FileAutoRenamer+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F39170A82CB8201B006127BC /* FileAutoRenamer+Extensions.swift */; };
152+
F39170AA2CB82024006127BC /* FileAutoRenamer+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F39170A82CB8201B006127BC /* FileAutoRenamer+Extensions.swift */; };
153+
F39170AB2CB82024006127BC /* FileAutoRenamer+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F39170A82CB8201B006127BC /* FileAutoRenamer+Extensions.swift */; };
154+
F39170AC2CB82024006127BC /* FileAutoRenamer+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F39170A82CB8201B006127BC /* FileAutoRenamer+Extensions.swift */; };
155+
F39170AD2CB82024006127BC /* FileAutoRenamer+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F39170A82CB8201B006127BC /* FileAutoRenamer+Extensions.swift */; };
156+
F39170AE2CB82024006127BC /* FileAutoRenamer+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F39170A82CB8201B006127BC /* FileAutoRenamer+Extensions.swift */; };
157+
F39170AF2CB82024006127BC /* FileAutoRenamer+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F39170A82CB8201B006127BC /* FileAutoRenamer+Extensions.swift */; };
151158
F39298972A3B12CB00509762 /* BaseNCMoreCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F39298962A3B12CB00509762 /* BaseNCMoreCell.swift */; };
152159
F3953BD72A6E87E000EE03F9 /* BaseIntegrationXCTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3953BD62A6E87E000EE03F9 /* BaseIntegrationXCTestCase.swift */; };
153160
F3A047972BD2668800658E7B /* NCAssistantEmptyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3A0478F2BD2668800658E7B /* NCAssistantEmptyView.swift */; };
@@ -1204,6 +1211,7 @@
12041211
F37208742BAB4AB0006B5430 /* TestConstants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestConstants.swift; sourceTree = "<group>"; };
12051212
F37208772BAB4B5D006B5430 /* BaseXCTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseXCTestCase.swift; sourceTree = "<group>"; };
12061213
F38F71242B6BBDC300473CDC /* NCCollectionViewCommonSelectTabBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCCollectionViewCommonSelectTabBar.swift; sourceTree = "<group>"; };
1214+
F39170A82CB8201B006127BC /* FileAutoRenamer+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileAutoRenamer+Extensions.swift"; sourceTree = "<group>"; };
12071215
F39298962A3B12CB00509762 /* BaseNCMoreCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseNCMoreCell.swift; sourceTree = "<group>"; };
12081216
F3953BD62A6E87E000EE03F9 /* BaseIntegrationXCTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseIntegrationXCTestCase.swift; sourceTree = "<group>"; };
12091217
F3998E192B4879B2007CA5DE /* CoreAudioTypes.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudioTypes.framework; path = System/Library/Frameworks/CoreAudioTypes.framework; sourceTree = SDKROOT; };
@@ -2849,6 +2857,7 @@
28492857
F7245923289BB50B00474787 /* ThreadSafeDictionary.swift */,
28502858
F33EE6F12BF4C9B200CA1A51 /* PKCS12.swift */,
28512859
F33918C32C7CD8F2002D9AA1 /* FileNameValidator+Extensions.swift */,
2860+
F39170A82CB8201B006127BC /* FileAutoRenamer+Extensions.swift */,
28522861
);
28532862
path = Utility;
28542863
sourceTree = "<group>";
@@ -4017,6 +4026,7 @@
40174026
files = (
40184027
F73EF7BD2B0224AB0087E6E9 /* NCManageDatabase+ExternalSites.swift in Sources */,
40194028
F71433E72C778FFB00E20B5A /* NotificationCenter+MainThread.swift in Sources */,
4029+
F39170AA2CB82024006127BC /* FileAutoRenamer+Extensions.swift in Sources */,
40204030
F73EF7C52B02250B0087E6E9 /* NCManageDatabase+GPS.swift in Sources */,
40214031
2C1D5D7923E2DE9100334ABB /* NCBrand.swift in Sources */,
40224032
F770768A263A8A2500A1BA94 /* NCUtilityFileSystem.swift in Sources */,
@@ -4151,6 +4161,7 @@
41514161
F757CC8729E7F88B00F31428 /* NCManageDatabase+Groupfolders.swift in Sources */,
41524162
F33EE6F72BF4C9B200CA1A51 /* PKCS12.swift in Sources */,
41534163
F7B769AD2B7A0B2000C1AAEB /* NCManageDatabase+Metadata+Session.swift in Sources */,
4164+
F39170AC2CB82024006127BC /* FileAutoRenamer+Extensions.swift in Sources */,
41544165
F73EF7BC2B0224AB0087E6E9 /* NCManageDatabase+ExternalSites.swift in Sources */,
41554166
F724377E2C10B92300C7C68D /* NCPermissions.swift in Sources */,
41564167
F73EF7B42B0224350087E6E9 /* NCManageDatabase+DirectEditing.swift in Sources */,
@@ -4232,6 +4243,7 @@
42324243
F7BD71E62636EAFC00643C34 /* NCNetworkingE2EE.swift in Sources */,
42334244
F7F878AF1FB9E3B900599E4F /* NCEndToEndMetadata.swift in Sources */,
42344245
F7327E3B2B73B8D600A462C7 /* Array+Extension.swift in Sources */,
4246+
F39170AF2CB82024006127BC /* FileAutoRenamer+Extensions.swift in Sources */,
42354247
F799DF832C4B7DCC003410B5 /* NCSectionFooter.swift in Sources */,
42364248
AF22B218277D196700DAB0CC /* NCShareExtension+Files.swift in Sources */,
42374249
F799DF862C4B7E56003410B5 /* NCSectionHeader.swift in Sources */,
@@ -4306,6 +4318,7 @@
43064318
F73EF7D02B0225BA0087E6E9 /* NCManageDatabase+Tag.swift in Sources */,
43074319
F783030228B4C4B800B84583 /* NCUtility.swift in Sources */,
43084320
F711D63128F44801003F43C8 /* IntentHandler.swift in Sources */,
4321+
F39170AE2CB82024006127BC /* FileAutoRenamer+Extensions.swift in Sources */,
43094322
F76DEE9728F808AF0041B1C9 /* LockscreenData.swift in Sources */,
43104323
F72EA95A28B7BD0D00C88F0C /* FilesWidgetView.swift in Sources */,
43114324
F768823C2C0DD231001CF441 /* NCKeychain.swift in Sources */,
@@ -4449,6 +4462,7 @@
44494462
F7BFFD2C2C8854690029A201 /* NCHud.swift in Sources */,
44504463
F771E3F820E239B500AFB62D /* FileProviderExtension+Thumbnail.swift in Sources */,
44514464
F76882392C0DD230001CF441 /* NCKeychain.swift in Sources */,
4465+
F39170AB2CB82024006127BC /* FileAutoRenamer+Extensions.swift in Sources */,
44524466
F343A4BF2A1E734600DDA874 /* Optional+Extension.swift in Sources */,
44534467
AF4BF62027562B3F0081CEEF /* NCManageDatabase+Activity.swift in Sources */,
44544468
F73ADD2226554FD10069EA0D /* NCContentPresenter.swift in Sources */,
@@ -4467,6 +4481,7 @@
44674481
F7E7AEA72BA32D0000512E52 /* NCCollectionViewUnifiedSearch.swift in Sources */,
44684482
F73EF7A72B0223900087E6E9 /* NCManageDatabase+Comments.swift in Sources */,
44694483
F33918C42C7CD8F2002D9AA1 /* FileNameValidator+Extensions.swift in Sources */,
4484+
F39170AD2CB82024006127BC /* FileAutoRenamer+Extensions.swift in Sources */,
44704485
F799DF882C4B83CC003410B5 /* NCCollectionViewCommon+EasyTipView.swift in Sources */,
44714486
F7AE00F8230E81CB007ACF8A /* NCBrowserWeb.swift in Sources */,
44724487
F77DD6A82C5CC093009448FB /* NCSession.swift in Sources */,
@@ -4770,6 +4785,7 @@
47704785
F7C9B91F2B582F550064EA91 /* NCManageDatabase+SecurityGuard.swift in Sources */,
47714786
F75DD767290ABB25002EB562 /* Intent.intentdefinition in Sources */,
47724787
F72437812C10B92500C7C68D /* NCPermissions.swift in Sources */,
4788+
F39170A92CB82024006127BC /* FileAutoRenamer+Extensions.swift in Sources */,
47734789
F749B64C297B0CBB00087535 /* NCManageDatabase+Share.swift in Sources */,
47744790
F7A8D73F28F181EF008BBE1C /* NCGlobal.swift in Sources */,
47754791
F74B6D972A7E239A00F03C5F /* NCManageDatabase+Chunk.swift in Sources */,
@@ -5682,7 +5698,7 @@
56825698
CLANG_WARN_UNREACHABLE_CODE = YES;
56835699
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
56845700
COPY_PHASE_STRIP = NO;
5685-
CURRENT_PROJECT_VERSION = 0;
5701+
CURRENT_PROJECT_VERSION = 2;
56865702
DEBUG_INFORMATION_FORMAT = dwarf;
56875703
DEVELOPMENT_TEAM = NKUJUXUJ3B;
56885704
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -5709,7 +5725,7 @@
57095725
"@executable_path/Frameworks",
57105726
"@executable_path/../../Frameworks",
57115727
);
5712-
MARKETING_VERSION = 6.1.3;
5728+
MARKETING_VERSION = 6.1.4;
57135729
ONLY_ACTIVE_ARCH = YES;
57145730
OTHER_CFLAGS = "-v";
57155731
OTHER_LDFLAGS = "";
@@ -5748,7 +5764,7 @@
57485764
CLANG_WARN_UNREACHABLE_CODE = YES;
57495765
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
57505766
COPY_PHASE_STRIP = NO;
5751-
CURRENT_PROJECT_VERSION = 0;
5767+
CURRENT_PROJECT_VERSION = 2;
57525768
DEVELOPMENT_TEAM = NKUJUXUJ3B;
57535769
ENABLE_STRICT_OBJC_MSGSEND = YES;
57545770
ENABLE_TESTABILITY = YES;
@@ -5772,7 +5788,7 @@
57725788
"@executable_path/Frameworks",
57735789
"@executable_path/../../Frameworks",
57745790
);
5775-
MARKETING_VERSION = 6.1.3;
5791+
MARKETING_VERSION = 6.1.4;
57765792
ONLY_ACTIVE_ARCH = YES;
57775793
OTHER_CFLAGS = "-v";
57785794
OTHER_LDFLAGS = "";
@@ -6047,7 +6063,7 @@
60476063
repositoryURL = "https://github.com/nextcloud/NextcloudKit";
60486064
requirement = {
60496065
kind = exactVersion;
6050-
version = 5.0.0;
6066+
version = 5.0.1;
60516067
};
60526068
};
60536069
F788ECC5263AAAF900ADC67F /* XCRemoteSwiftPackageReference "MarkdownKit" */ = {

Share/NCShareCell.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import NextcloudKit
2727
protocol NCShareCellDelegate: AnyObject {
2828
var uploadStarted: Bool { get }
2929
func removeFile(named fileName: String)
30-
func renameFile(named fileName: String, account: String)
30+
func showRenameFileDialog(named fileName: String, account: String)
31+
func renameFile(oldName: String, newName: String, account: String)
3132
}
3233

3334
class NCShareCell: UITableViewCell {
@@ -71,7 +72,7 @@ class NCShareCell: UITableViewCell {
7172
let alertController = UIAlertController(title: "", message: fileName, preferredStyle: .alert)
7273

7374
alertController.addAction(UIAlertAction(title: NSLocalizedString("_rename_file_", comment: ""), style: .default) { _ in
74-
self.delegate?.renameFile(named: self.fileName, account: self.account)
75+
self.delegate?.showRenameFileDialog(named: self.fileName, account: self.account)
7576
})
7677

7778
alertController.addAction(UIAlertAction(title: NSLocalizedString("_remove_file_", comment: ""), style: .default) { _ in

Share/NCShareExtension+DataSource.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ extension NCShareExtension: UITableViewDelegate {
176176
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
177177
guard !uploadStarted else { return }
178178
let fileName = filesName[indexPath.row]
179-
renameFile(named: fileName, account: session.account)
179+
showRenameFileDialog(named: fileName, account: session.account)
180180
}
181181
}
182182

Share/NCShareExtension+NCAccountRequestDelegate.swift

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,25 @@ extension NCShareExtension: NCCreateFormUploadConflictDelegate {
111111
}
112112

113113
extension NCShareExtension: NCShareCellDelegate {
114-
func renameFile(named fileName: String, account: String) {
114+
func showRenameFileDialog(named fileName: String, account: String) {
115115
let alert = UIAlertController.renameFile(fileName: fileName, account: account) { [self] newFileName in
116-
guard let fileIx = self.filesName.firstIndex(of: fileName),
117-
!self.filesName.contains(newFileName),
118-
utilityFileSystem.moveFile(atPath: (NSTemporaryDirectory() + fileName), toPath: (NSTemporaryDirectory() + newFileName)) else {
119-
return showAlert(title: "_single_file_conflict_title_", description: "'\(fileName)' -> '\(newFileName)'")
120-
}
121-
122-
filesName[fileIx] = newFileName
123-
tableView.reloadData()
116+
renameFile(oldName: fileName, newName: newFileName, account: account)
124117
}
125118

126119
present(alert, animated: true)
127120
}
128121

122+
func renameFile(oldName: String, newName: String, account: String) {
123+
guard let fileIx = self.filesName.firstIndex(of: oldName),
124+
!self.filesName.contains(newName),
125+
utilityFileSystem.moveFile(atPath: (NSTemporaryDirectory() + oldName), toPath: (NSTemporaryDirectory() + newName)) else {
126+
return showAlert(title: "_single_file_conflict_title_", description: "'\(oldName)' -> '\(newName)'")
127+
}
128+
129+
filesName[fileIx] = newName
130+
tableView.reloadData()
131+
}
132+
129133
func removeFile(named fileName: String) {
130134
guard let index = self.filesName.firstIndex(of: fileName) else {
131135
return showAlert(title: "_file_not_found_", description: fileName)

Share/NCShareExtension.swift

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,17 +285,41 @@ extension NCShareExtension {
285285
guard !filesName.isEmpty else { return showAlert(description: "_files_no_files_") }
286286

287287
counterUploaded = 0
288-
uploadStarted = true
289288
uploadErrors = []
289+
var dismissAfterUpload = true
290290

291291
var conflicts: [tableMetadata] = []
292-
for fileName in filesName {
293-
if let fileNameError = FileNameValidator.shared.checkFileName(fileName, account: session.account) {
294-
present(UIAlertController.warning(message: "\(fileNameError.errorDescription) \(NSLocalizedString("_please_rename_file_", comment: ""))"), animated: true)
292+
var invalidNameIndexes: [Int] = []
293+
294+
for (index, fileName) in filesName.enumerated() {
295+
let newFileName = FileAutoRenamer.shared.rename(fileName, account: session.account)
296+
297+
if fileName != newFileName {
298+
renameFile(oldName: fileName, newName: newFileName, account: session.account)
299+
}
300+
301+
if let fileNameError = FileNameValidator.shared.checkFileName(newFileName, account: session.account) {
302+
if filesName.count == 1 {
303+
showRenameFileDialog(named: fileName, account: account)
304+
return
305+
} else {
306+
present(UIAlertController.warning(message: "\(fileNameError.errorDescription) \(NSLocalizedString("_please_rename_file_", comment: ""))") {
307+
self.extensionContext?.completeRequest(returningItems: self.extensionContext?.inputItems, completionHandler: nil)
308+
}, animated: true)
309+
310+
invalidNameIndexes.append(index)
311+
dismissAfterUpload = false
312+
continue
313+
}
295314

296-
continue
297315
}
316+
}
317+
318+
for index in invalidNameIndexes.reversed() {
319+
filesName.remove(at: index)
320+
}
298321

322+
for fileName in filesName {
299323
let ocId = NSUUID().uuidString
300324
let toPath = utilityFileSystem.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName)
301325
guard utilityFileSystem.copyFile(atPath: (NSTemporaryDirectory() + fileName), toPath: toPath) else { continue }
@@ -320,6 +344,8 @@ extension NCShareExtension {
320344
}
321345
}
322346

347+
tableView.reloadData()
348+
323349
if !conflicts.isEmpty {
324350
guard let conflict = UIStoryboard(name: "NCCreateFormUploadConflict", bundle: nil).instantiateInitialViewController() as? NCCreateFormUploadConflict
325351
else { return }
@@ -330,13 +356,14 @@ extension NCShareExtension {
330356
conflict.delegate = self
331357
self.present(conflict, animated: true, completion: nil)
332358
} else {
333-
upload()
359+
uploadStarted = true
360+
upload(dismissAfterUpload: dismissAfterUpload)
334361
}
335362
}
336363

337-
func upload() {
364+
func upload(dismissAfterUpload: Bool = true) {
338365
guard uploadStarted else { return }
339-
guard uploadMetadata.count > counterUploaded else { return DispatchQueue.main.async { self.finishedUploading() } }
366+
guard uploadMetadata.count > counterUploaded else { return DispatchQueue.main.async { self.finishedUploading(dismissAfterUpload: dismissAfterUpload) } }
340367
let metadata = uploadMetadata[counterUploaded]
341368
let results = NextcloudKit.shared.nkCommonInstance.getInternalType(fileName: metadata.fileNameView, mimeType: metadata.contentType, directory: false, account: session.account)
342369

@@ -374,7 +401,7 @@ extension NCShareExtension {
374401
}
375402
}
376403

377-
func finishedUploading() {
404+
func finishedUploading(dismissAfterUpload: Bool = true) {
378405
uploadStarted = false
379406
if !uploadErrors.isEmpty {
380407
let fileList = "- " + uploadErrors.map({ $0.fileName }).joined(separator: "\n - ")

iOSClient/Data/NCManageDatabase+Metadata.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ extension tableMetadata {
253253
status == NCGlobal.shared.metadataStatusWaitUpload || status == NCGlobal.shared.metadataStatusUploading
254254
}
255255

256+
var isDirectory: Bool {
257+
directory
258+
}
259+
256260
@objc var isDirectoryE2EE: Bool {
257261
let session = NCSession.Session(account: account, urlBase: urlBase, user: user, userId: userId)
258262
return NCUtilityFileSystem().isDirectoryE2EE(session: session, serverUrl: serverUrl)

0 commit comments

Comments
 (0)