From 154a5ccc38fa07d3c1db14f18514bfd6b2296832 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Wed, 6 Nov 2024 09:53:44 +0100 Subject: [PATCH] Version V 5.0.1 (#103) * https://github.com/nextcloud/ios/issues/2390 Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> * add async/await searchMedia Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> * Livephoto detect (#51) * Update NKModel.swift * cleaning Signed-off-by: Marino Faggiana * Fix build on macOS broken by freeDisk change (#53) Signed-off-by: Claudio Cambra * livePhotoFile -> fileId Signed-off-by: Marino Faggiana * rollback Signed-off-by: Marino Faggiana * rollback Signed-off-by: Marino Faggiana * Fix error description chunk Signed-off-by: Marino Faggiana * chunk error fix Signed-off-by: Marino Faggiana * errorDescription Signed-off-by: Marino Faggiana * added description Signed-off-by: Marino Faggiana * Change to markdown Signed-off-by: Milen Pivchev * Added e2ee options versionApi Signed-off-by: Marino Faggiana * change variable name Signed-off-by: Marino Faggiana * endpoint update Signed-off-by: Marino Faggiana * Fix chunk S3 (#56) * cod Signed-off-by: Marino Faggiana * fix Signed-off-by: Marino Faggiana --------- Signed-off-by: Marino Faggiana * public func Signed-off-by: Marino Faggiana * lint Signed-off-by: Marino Faggiana * remove description Signed-off-by: Marino Faggiana * fix Signed-off-by: Marino Faggiana * fix Signed-off-by: Marino Faggiana * fix log Signed-off-by: Marino Faggiana * Resolution - GPS (#59) * fix resolution-gps Signed-off-by: Marino Faggiana --------- Signed-off-by: Marino Faggiana * set h, w to Double Signed-off-by: Marino Faggiana * coding (#61) Signed-off-by: Marino Faggiana * normalized taskHandler taskHandler(task) }. Signed-off-by: Marino Faggiana * add filename in trash (#63) * add filename Signed-off-by: Marino Faggiana * disable Build and test Signed-off-by: Marino Faggiana --------- Signed-off-by: Marino Faggiana * Nextcloud Assistant (#66) * getTextProcessingTaskTypes Signed-off-by: Marino Faggiana * getTextProcessingTaskTypes Signed-off-by: Marino Faggiana * NKTextProcessingTaskTypes Signed-off-by: Marino Faggiana * coding Signed-off-by: Marino Faggiana * coding Signed-off-by: Marino Faggiana * coding Signed-off-by: Marino Faggiana * coding Signed-off-by: Marino Faggiana * fix Signed-off-by: Marino Faggiana * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * Add init Signed-off-by: Milen Pivchev * Change model Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev --------- Signed-off-by: Marino Faggiana Signed-off-by: Milen Pivchev Co-authored-by: Milen Pivchev * Add support for visionOS, fix tvOS and watchOS support (#67) * Add CoreServices import for visionOS Signed-off-by: Claudio Cambra * Fix screen scaling calculation when UIScreen is not available (for visionOS) Signed-off-by: Claudio Cambra * Fix availability of UIImage.resizeImage on non iOS platforms Signed-off-by: Claudio Cambra * Add visionOS target support to NextcloudKit Signed-off-by: Claudio Cambra * Bump watchOS version up, per dependency requirements Signed-off-by: Claudio Cambra * Remove reachability observation on watchOS, as this is unsupported in Alamofire Signed-off-by: Claudio Cambra * Remove free disk calculation on watchOS which cannot be done Signed-off-by: Claudio Cambra * Bump up tvOS version per dependencies Signed-off-by: Claudio Cambra * Also restrict free space calculation on tvOS, as unavailable Signed-off-by: Claudio Cambra --------- Signed-off-by: Claudio Cambra * Task description (#70) * coding Signed-off-by: Marino Faggiana * task.taskDescription Signed-off-by: Marino Faggiana * DownloadingFinish Signed-off-by: Marino Faggiana * fix Signed-off-by: Marino Faggiana * improvements Signed-off-by: Marino Faggiana * fix Signed-off-by: Marino Faggiana --------- Signed-off-by: Marino Faggiana * change TypeIconFile (#71) Signed-off-by: Marino Faggiana * Core Preview Improvements and use only fileId Signed-off-by: Marino Faggiana * fix Signed-off-by: Marino Faggiana * improvements Signed-off-by: Marino Faggiana * Improvements Signed-off-by: Marino Faggiana * added compressionQuality Signed-off-by: Marino Faggiana * Improvements (#76) Signed-off-by: Marino Faggiana * improved code Signed-off-by: Marino Faggiana * fix paramenters default Signed-off-by: Marino Faggiana * fix paramenters default Signed-off-by: Marino Faggiana * improvements Signed-off-by: Marino Faggiana * cod Signed-off-by: Marino Faggiana * improvements Signed-off-by: Marino Faggiana * downloadPreview Signed-off-by: Marino Faggiana * added downloadPreview url Signed-off-by: Marino Faggiana * httpCookieStorage (#80) Signed-off-by: Marino Faggiana * new getUserProfile() Signed-off-by: Marino Faggiana * change paramenter name Signed-off-by: Marino Faggiana * Account (#82) * cod Signed-off-by: Marino Faggiana * cod Signed-off-by: Marino Faggiana * cod Signed-off-by: Marino Faggiana --------- Signed-off-by: Marino Faggiana * cod Signed-off-by: Marino Faggiana * Revert "cod" This reverts commit 83b75a17686ad446e7f720c28b542c5cabdda4c9. Signed-off-by: Marino Faggiana * Filename validator (#83) * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * cleanup Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * Make singleton Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev --------- Signed-off-by: Milen Pivchev * fix session delegate Signed-off-by: Marino Faggiana * fix Signed-off-by: Marino Faggiana * Filename validator (#92) * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * cleanup Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * Make singleton Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev --------- Signed-off-by: Milen Pivchev Co-authored-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * NextcloudKit Version 5 - Multisession (#94) --------- Signed-off-by: Marino Faggiana Signed-off-by: Milen Pivchev Co-authored-by: Milen Pivchev * NextcloudKit V 5 Signed-off-by: Marino Faggiana * fix Signed-off-by: Marino Faggiana * requestCachePolicy Signed-off-by: Marino Faggiana * cache Signed-off-by: Marino Faggiana * cache Signed-off-by: Marino Faggiana * cache Signed-off-by: Marino Faggiana * Add optional spaces and periods - WCF Signed-off-by: Milen Pivchev WIP Signed-off-by: Milen Pivchev WIP Signed-off-by: Milen Pivchev WIP Signed-off-by: Milen Pivchev WIP Signed-off-by: Milen Pivchev WIP Signed-off-by: Milen Pivchev * Response (#97) * API Signed-off-by: Marino Faggiana * assistant Signed-off-by: Marino Faggiana * comments Signed-off-by: Marino Faggiana * dashboard Signed-off-by: Marino Faggiana * e2ee Signed-off-by: Marino Faggiana * groupfolders Signed-off-by: Marino Faggiana * hovercard Signed-off-by: Marino Faggiana * login Signed-off-by: Marino Faggiana * nctext Signed-off-by: Marino Faggiana * pn Signed-off-by: Marino Faggiana * richdocuments Signed-off-by: Marino Faggiana * search Signed-off-by: Marino Faggiana * share Signed-off-by: Marino Faggiana * userstatus Signed-off-by: Marino Faggiana * webdav Signed-off-by: Marino Faggiana * upload Signed-off-by: Marino Faggiana * API Signed-off-by: Marino Faggiana * download Signed-off-by: Marino Faggiana * upload Signed-off-by: Marino Faggiana * NextcloudKitSessionDelegate Signed-off-by: Marino Faggiana * normalized Signed-off-by: Marino Faggiana --------- Signed-off-by: Marino Faggiana * ThreadSafeArray Signed-off-by: Marino Faggiana * logger delegate Signed-off-by: Marino Faggiana * fix message 503 Signed-off-by: Marino Faggiana * public Signed-off-by: Marino Faggiana * fix error Signed-off-by: Marino Faggiana * Add reuse compliance (#96) * Auto rename (#99) * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * License Signed-off-by: Milen Pivchev * Licenses Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * Swiftlint fixes Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * Fix lint issue Signed-off-by: Milen Pivchev * Fix ordering Signed-off-by: Milen Pivchev * Refactor Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * License Signed-off-by: Milen Pivchev * Licenses Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * Swiftlint fixes Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * Fix lint issue Signed-off-by: Milen Pivchev * Fix ordering Signed-off-by: Milen Pivchev * Refactor Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev * WIP Signed-off-by: Milen Pivchev --------- Signed-off-by: Milen Pivchev Co-authored-by: Marino Faggiana * Keep original extension Signed-off-by: Milen Pivchev * Refactor Signed-off-by: Milen Pivchev * License (#102) Signed-off-by: Marino Faggiana * ( multipathServiceType ) Signed-off-by: Marino Faggiana --------- Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Signed-off-by: Marino Faggiana Signed-off-by: Claudio Cambra Signed-off-by: Milen Pivchev Co-authored-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com> Co-authored-by: Claudio Cambra Co-authored-by: Milen Pivchev Co-authored-by: Andy Scherzinger --- .swiftlint.yml | 2 + .../Extensions/Image+Extension.swift | 7 +- .../Extensions/String+Extension.swift | 5 +- Sources/NextcloudKit/NKCommon.swift | 8 +- Sources/NextcloudKit/NKError.swift | 6 +- Sources/NextcloudKit/NKLogger.swift | 6 +- Sources/NextcloudKit/NKModel.swift | 18 +- Sources/NextcloudKit/NKRequestOptions.swift | 6 +- Sources/NextcloudKit/NKSession.swift | 9 +- Sources/NextcloudKit/NKShareAccounts.swift | 5 +- Sources/NextcloudKit/NextcloudKit+API.swift | 6 +- .../NextcloudKit/NextcloudKit+Assistant.swift | 18 +- .../NextcloudKit/NextcloudKit+Comments.swift | 9 +- .../NextcloudKit/NextcloudKit+Dashboard.swift | 9 +- .../NextcloudKit/NextcloudKit+Download.swift | 5 +- Sources/NextcloudKit/NextcloudKit+E2EE.swift | 5 +- .../NextcloudKit/NextcloudKit+FilesLock.swift | 5 +- .../NextcloudKit+Groupfolders.swift | 6 +- .../NextcloudKit/NextcloudKit+Hovercard.swift | 7 +- .../NextcloudKit/NextcloudKit+Livephoto.swift | 5 +- Sources/NextcloudKit/NextcloudKit+Login.swift | 5 +- .../NextcloudKit/NextcloudKit+NCText.swift | 5 +- .../NextcloudKit+PushNotification.swift | 5 +- .../NextcloudKit+Richdocuments.swift | 5 +- .../NextcloudKit/NextcloudKit+Search.swift | 6 +- Sources/NextcloudKit/NextcloudKit+Share.swift | 11 +- .../NextcloudKit/NextcloudKit+Upload.swift | 6 +- .../NextcloudKit+UserStatus.swift | 5 +- .../NextcloudKit/NextcloudKit+WebDAV.swift | 5 +- Sources/NextcloudKit/NextcloudKit.h | 5 +- Sources/NextcloudKit/NextcloudKit.swift | 7 +- .../NextcloudKit/NextcloudKitBackground.swift | 5 +- .../NextcloudKitSessionDelegate.swift | 8 +- .../NextcloudKit/Utils/FileAutoRenamer.swift | 108 +++++++++++ .../Utils/FileNameValidator.swift | 17 +- .../NextcloudKit/Utils/ThreadSafeArray.swift | 5 +- .../BaseIntegrationXCTestCase.swift | 5 +- .../FilesIntegrationTests.swift | 79 ++++---- .../ShareIntegrationTests.swift | 43 +++-- .../FileAutoRenamerUnitTests.swift | 175 ++++++++++++++++++ ...swift => FileNameValidatorUnitTests.swift} | 49 +---- .../LoginUnitTests.swift | 13 +- 42 files changed, 469 insertions(+), 250 deletions(-) create mode 100644 Sources/NextcloudKit/Utils/FileAutoRenamer.swift create mode 100644 Tests/NextcloudKitUnitTests/FileAutoRenamerUnitTests.swift rename Tests/NextcloudKitUnitTests/{FileNameValidatorTests.swift => FileNameValidatorUnitTests.swift} (74%) diff --git a/.swiftlint.yml b/.swiftlint.yml index 99b53809..9d2f297c 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -46,5 +46,7 @@ excluded: - Pods - Package.swift - Tests + - DerivedData + - .build reporter: "xcode" diff --git a/Sources/NextcloudKit/Extensions/Image+Extension.swift b/Sources/NextcloudKit/Extensions/Image+Extension.swift index ef660981..c45c6789 100644 --- a/Sources/NextcloudKit/Extensions/Image+Extension.swift +++ b/Sources/NextcloudKit/Extensions/Image+Extension.swift @@ -1,7 +1,7 @@ -// -// SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2020 Marino Faggiana +// SPDX-FileCopyrightText: 2021 Henrik Storch // SPDX-License-Identifier: GPL-3.0-or-later -// #if os(macOS) import Foundation @@ -80,4 +80,3 @@ extension UIImage { } } #endif - diff --git a/Sources/NextcloudKit/Extensions/String+Extension.swift b/Sources/NextcloudKit/Extensions/String+Extension.swift index c3826f2e..ebfcde33 100644 --- a/Sources/NextcloudKit/Extensions/String+Extension.swift +++ b/Sources/NextcloudKit/Extensions/String+Extension.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2023 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire diff --git a/Sources/NextcloudKit/NKCommon.swift b/Sources/NextcloudKit/NKCommon.swift index c119369f..2b0650fa 100644 --- a/Sources/NextcloudKit/NKCommon.swift +++ b/Sources/NextcloudKit/NKCommon.swift @@ -1,7 +1,7 @@ -// -// SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2019 Marino Faggiana +// SPDX-FileCopyrightText: 2023 Claudio Cambra // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire @@ -274,7 +274,7 @@ public class NKCommon: NSObject { // MARK: - Chunked File - public func chunkedFile(inputDirectory: String, + public func chunkedFile(inputDirectory: String, outputDirectory: String, fileName: String, chunkSize: Int, diff --git a/Sources/NextcloudKit/NKError.swift b/Sources/NextcloudKit/NKError.swift index 35633a34..f162a261 100644 --- a/Sources/NextcloudKit/NKError.swift +++ b/Sources/NextcloudKit/NKError.swift @@ -1,7 +1,7 @@ -// -// SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2022 Henrik Sorch +// SPDX-FileCopyrightText: 2023 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire diff --git a/Sources/NextcloudKit/NKLogger.swift b/Sources/NextcloudKit/NKLogger.swift index 6c005cda..5b85215b 100644 --- a/Sources/NextcloudKit/NKLogger.swift +++ b/Sources/NextcloudKit/NKLogger.swift @@ -1,8 +1,6 @@ -// -// SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2019 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// - import Foundation import Alamofire diff --git a/Sources/NextcloudKit/NKModel.swift b/Sources/NextcloudKit/NKModel.swift index cc5b8e10..dc843a04 100644 --- a/Sources/NextcloudKit/NKModel.swift +++ b/Sources/NextcloudKit/NKModel.swift @@ -1,7 +1,7 @@ -// -// SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2019 Marino Faggiana +// SPDX-FileCopyrightText: 2023 Claudio Cambra // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation @@ -355,7 +355,7 @@ class NKDataFileXML: NSObject { """ func getRequestBodyFile(createProperties: [NKProperties]?, removeProperties: [NKProperties] = []) -> String { - let request = """ + let request = """ @@ -379,7 +379,7 @@ class NKDataFileXML: NSObject { """ func getRequestBodyFileListingFavorites(createProperties: [NKProperties]?, removeProperties: [NKProperties] = []) -> String { - let request = """ + let request = """ @@ -394,7 +394,7 @@ class NKDataFileXML: NSObject { } func getRequestBodySearchFileName(createProperties: [NKProperties]?, removeProperties: [NKProperties] = []) -> String { - let request = """ + let request = """ @@ -422,7 +422,7 @@ class NKDataFileXML: NSObject { } func getRequestBodySearchFileId(createProperties: [NKProperties]?, removeProperties: [NKProperties] = []) -> String { - let request = """ + let request = """ @@ -450,7 +450,7 @@ class NKDataFileXML: NSObject { } func getRequestBodySearchMedia(createProperties: [NKProperties]?, removeProperties: [NKProperties] = []) -> String { - let request = """ + let request = """ @@ -508,7 +508,7 @@ class NKDataFileXML: NSObject { } func getRequestBodySearchMediaWithLimit(createProperties: [NKProperties]?, removeProperties: [NKProperties] = []) -> String { - let request = """ + let request = """ diff --git a/Sources/NextcloudKit/NKRequestOptions.swift b/Sources/NextcloudKit/NKRequestOptions.swift index 7a0f03fd..e7bdeecd 100644 --- a/Sources/NextcloudKit/NKRequestOptions.swift +++ b/Sources/NextcloudKit/NKRequestOptions.swift @@ -1,7 +1,7 @@ -// -// SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2021 Henrik Sorch +// SPDX-FileCopyrightText: 2021 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation diff --git a/Sources/NextcloudKit/NKSession.swift b/Sources/NextcloudKit/NKSession.swift index d2c49826..d24fe5ed 100644 --- a/Sources/NextcloudKit/NKSession.swift +++ b/Sources/NextcloudKit/NKSession.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2024 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire @@ -50,6 +49,7 @@ public class NKSession { /// Session Alamofire let configuration = URLSessionConfiguration.af.default configuration.requestCachePolicy = requestCachePolicy + configuration.multipathServiceType = .handover configuration.httpCookieStorage = HTTPCookieStorage.sharedCookieStorage(forGroupContainerIdentifier: sharedCookieStorage) sessionData = Alamofire.Session(configuration: configuration, delegate: NextcloudKitSessionDelegate(nkCommonInstance: NextcloudKit.shared.nkCommonInstance), @@ -65,6 +65,7 @@ public class NKSession { configurationDownloadBackground.isDiscretionary = false configurationDownloadBackground.httpMaximumConnectionsPerHost = 5 configurationDownloadBackground.requestCachePolicy = requestCachePolicy + configurationDownloadBackground.multipathServiceType = .handover configurationDownloadBackground.httpCookieStorage = HTTPCookieStorage.sharedCookieStorage(forGroupContainerIdentifier: sharedCookieStorage) sessionDownloadBackground = URLSession(configuration: configurationDownloadBackground, delegate: backgroundSessionDelegate, delegateQueue: OperationQueue.main) @@ -75,6 +76,7 @@ public class NKSession { configurationUploadBackground.isDiscretionary = false configurationUploadBackground.httpMaximumConnectionsPerHost = 5 configurationUploadBackground.requestCachePolicy = requestCachePolicy + configurationUploadBackground.multipathServiceType = .handover configurationUploadBackground.httpCookieStorage = HTTPCookieStorage.sharedCookieStorage(forGroupContainerIdentifier: sharedCookieStorage) sessionUploadBackground = URLSession(configuration: configurationUploadBackground, delegate: backgroundSessionDelegate, delegateQueue: OperationQueue.main) @@ -96,6 +98,7 @@ public class NKSession { configurationUploadBackgroundExt.httpMaximumConnectionsPerHost = 5 configurationUploadBackgroundExt.requestCachePolicy = requestCachePolicy configurationUploadBackgroundExt.sharedContainerIdentifier = groupIdentifier + configurationUploadBackgroundExt.multipathServiceType = .handover configurationUploadBackgroundExt.httpCookieStorage = HTTPCookieStorage.sharedCookieStorage(forGroupContainerIdentifier: sharedCookieStorage) sessionUploadBackgroundExt = URLSession(configuration: configurationUploadBackgroundExt, delegate: backgroundSessionDelegate, delegateQueue: OperationQueue.main) } diff --git a/Sources/NextcloudKit/NKShareAccounts.swift b/Sources/NextcloudKit/NKShareAccounts.swift index 3bf85026..e9dcb00f 100644 --- a/Sources/NextcloudKit/NKShareAccounts.swift +++ b/Sources/NextcloudKit/NKShareAccounts.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2023 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation #if os(iOS) diff --git a/Sources/NextcloudKit/NextcloudKit+API.swift b/Sources/NextcloudKit/NextcloudKit+API.swift index 8eb30b15..a9ad6158 100644 --- a/Sources/NextcloudKit/NextcloudKit+API.swift +++ b/Sources/NextcloudKit/NextcloudKit+API.swift @@ -1,7 +1,7 @@ -// -// SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2022 Marino Faggiana +// SPDX-FileCopyrightText: 2023 Claudio Cambra // SPDX-License-Identifier: GPL-3.0-or-later -// #if os(macOS) import Foundation diff --git a/Sources/NextcloudKit/NextcloudKit+Assistant.swift b/Sources/NextcloudKit/NextcloudKit+Assistant.swift index 9307c5e4..1b558de2 100644 --- a/Sources/NextcloudKit/NextcloudKit+Assistant.swift +++ b/Sources/NextcloudKit/NextcloudKit+Assistant.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2024 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire @@ -16,7 +15,7 @@ public extension NextcloudKit { guard let nkSession = nkCommonInstance.getSession(account: account), let url = nkCommonInstance.createStandardUrl(serverUrl: nkSession.urlBase, endpoint: endpoint, options: options), let headers = nkCommonInstance.getStandardHeaders(account: account, options: options) else { - return options.queue.async { completion(account, nil,nil, .urlError) } + return options.queue.async { completion(account, nil, nil, .urlError) } } nkSession.sessionData.request(url, method: .get, encoding: URLEncoding.default, headers: headers, interceptor: nil).validate(statusCode: 200..<300).onURLSessionTaskCreation { task in @@ -56,7 +55,7 @@ public extension NextcloudKit { guard let nkSession = nkCommonInstance.getSession(account: account), let url = nkCommonInstance.createStandardUrl(serverUrl: nkSession.urlBase, endpoint: endpoint, options: options), let headers = nkCommonInstance.getStandardHeaders(account: account, options: options) else { - return options.queue.async { completion(account, nil,nil, .urlError) } + return options.queue.async { completion(account, nil, nil, .urlError) } } let parameters: [String: Any] = ["input": input, "type": typeId, "appId": appId, "identifier": identifier] @@ -94,7 +93,7 @@ public extension NextcloudKit { guard let nkSession = nkCommonInstance.getSession(account: account), let url = nkCommonInstance.createStandardUrl(serverUrl: nkSession.urlBase, endpoint: endpoint, options: options), let headers = nkCommonInstance.getStandardHeaders(account: account, options: options) else { - return options.queue.async { completion(account, nil,nil, .urlError) } + return options.queue.async { completion(account, nil, nil, .urlError) } } nkSession.sessionData.request(url, method: .get, encoding: URLEncoding.default, headers: headers, interceptor: nil).validate(statusCode: 200..<300).onURLSessionTaskCreation { task in @@ -131,7 +130,7 @@ public extension NextcloudKit { guard let nkSession = nkCommonInstance.getSession(account: account), let url = nkCommonInstance.createStandardUrl(serverUrl: nkSession.urlBase, endpoint: endpoint, options: options), let headers = nkCommonInstance.getStandardHeaders(account: account, options: options) else { - return options.queue.async { completion(account, nil,nil, .urlError) } + return options.queue.async { completion(account, nil, nil, .urlError) } } nkSession.sessionData.request(url, method: .delete, encoding: URLEncoding.default, headers: headers, interceptor: nil).validate(statusCode: 200..<300).onURLSessionTaskCreation { task in @@ -168,7 +167,7 @@ public extension NextcloudKit { guard let nkSession = nkCommonInstance.getSession(account: account), let url = nkCommonInstance.createStandardUrl(serverUrl: nkSession.urlBase, endpoint: endpoint, options: options), let headers = nkCommonInstance.getStandardHeaders(account: account, options: options) else { - return options.queue.async { completion(account, nil,nil, .urlError) } + return options.queue.async { completion(account, nil, nil, .urlError) } } nkSession.sessionData.request(url, method: .get, encoding: URLEncoding.default, headers: headers, interceptor: nil).validate(statusCode: 200..<300).onURLSessionTaskCreation { task in @@ -261,7 +260,6 @@ public class NKTextProcessingTask { } static func factory(data: JSON) -> NKTextProcessingTask? { - NKTextProcessingTask.init(json: data) + NKTextProcessingTask(json: data) } } - diff --git a/Sources/NextcloudKit/NextcloudKit+Comments.swift b/Sources/NextcloudKit/NextcloudKit+Comments.swift index 53c0b68b..818bd325 100644 --- a/Sources/NextcloudKit/NextcloudKit+Comments.swift +++ b/Sources/NextcloudKit/NextcloudKit+Comments.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2022 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire @@ -17,7 +16,7 @@ public extension NextcloudKit { /// guard let nkSession = nkCommonInstance.getSession(account: account), let headers = nkCommonInstance.getStandardHeaders(account: account, options: options) else { - return options.queue.async { completion(account, nil,nil, .urlError) } + return options.queue.async { completion(account, nil, nil, .urlError) } } let serverUrlEndpoint = nkSession.urlBase + "/" + nkSession.dav + "/comments/files/\(fileId)" guard let url = serverUrlEndpoint.encodedToUrl else { @@ -143,7 +142,7 @@ public extension NextcloudKit { let error = NKError(error: error, afResponse: response, responseData: response.data) options.queue.async { completion(account, response, error) } case .success: - options.queue.async { completion(account, response ,.success) } + options.queue.async { completion(account, response, .success) } } } } diff --git a/Sources/NextcloudKit/NextcloudKit+Dashboard.swift b/Sources/NextcloudKit/NextcloudKit+Dashboard.swift index 8d8d3dfc..160b0122 100644 --- a/Sources/NextcloudKit/NextcloudKit+Dashboard.swift +++ b/Sources/NextcloudKit/NextcloudKit+Dashboard.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2022 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire @@ -17,7 +16,7 @@ public extension NextcloudKit { guard let nkSession = nkCommonInstance.getSession(account: account), let url = nkCommonInstance.createStandardUrl(serverUrl: nkSession.urlBase, endpoint: endpoint, options: options), let headers = nkCommonInstance.getStandardHeaders(account: account, options: options) else { - return options.queue.async { completion(account, nil,nil, .urlError) } + return options.queue.async { completion(account, nil, nil, .urlError) } } let dashboardRequest = nkSession.sessionData.request(url, method: .get, encoding: URLEncoding.default, headers: headers, interceptor: nil).validate(statusCode: 200..<300).onURLSessionTaskCreation { task in @@ -56,7 +55,7 @@ public extension NextcloudKit { guard let nkSession = nkCommonInstance.getSession(account: account), let url = nkCommonInstance.createStandardUrl(serverUrl: nkSession.urlBase, endpoint: endpoint, options: options), let headers = nkCommonInstance.getStandardHeaders(account: account, options: options) else { - return options.queue.async { completion(account, nil,nil, .urlError) } + return options.queue.async { completion(account, nil, nil, .urlError) } } let dashboardRequest = nkSession.sessionData.request(url, method: .get, encoding: URLEncoding.default, headers: headers, interceptor: nil).validate(statusCode: 200..<300).onURLSessionTaskCreation { task in diff --git a/Sources/NextcloudKit/NextcloudKit+Download.swift b/Sources/NextcloudKit/NextcloudKit+Download.swift index 25cd8def..16081acb 100644 --- a/Sources/NextcloudKit/NextcloudKit+Download.swift +++ b/Sources/NextcloudKit/NextcloudKit+Download.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2020 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire diff --git a/Sources/NextcloudKit/NextcloudKit+E2EE.swift b/Sources/NextcloudKit/NextcloudKit+E2EE.swift index 00e336e1..38f6af7d 100644 --- a/Sources/NextcloudKit/NextcloudKit+E2EE.swift +++ b/Sources/NextcloudKit/NextcloudKit+E2EE.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2022 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire diff --git a/Sources/NextcloudKit/NextcloudKit+FilesLock.swift b/Sources/NextcloudKit/NextcloudKit+FilesLock.swift index c70f45f7..c9d5678e 100644 --- a/Sources/NextcloudKit/NextcloudKit+FilesLock.swift +++ b/Sources/NextcloudKit/NextcloudKit+FilesLock.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2022 Henrik Sorch // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire diff --git a/Sources/NextcloudKit/NextcloudKit+Groupfolders.swift b/Sources/NextcloudKit/NextcloudKit+Groupfolders.swift index 3b2db639..80413c3d 100644 --- a/Sources/NextcloudKit/NextcloudKit+Groupfolders.swift +++ b/Sources/NextcloudKit/NextcloudKit+Groupfolders.swift @@ -1,7 +1,7 @@ -// -// SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2023 Henrik Storch +// SPDX-FileCopyrightText: 2023 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire diff --git a/Sources/NextcloudKit/NextcloudKit+Hovercard.swift b/Sources/NextcloudKit/NextcloudKit+Hovercard.swift index d1a621be..b5ba2dd6 100644 --- a/Sources/NextcloudKit/NextcloudKit+Hovercard.swift +++ b/Sources/NextcloudKit/NextcloudKit+Hovercard.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2021 Henrik Sorch // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire @@ -50,7 +49,7 @@ public extension NextcloudKit { public class NKHovercard: NSObject { public let userId, displayName: String public let actions: [Action] - + init?(jsonData: JSON) { guard let userId = jsonData["userId"].string, let displayName = jsonData["displayName"].string, diff --git a/Sources/NextcloudKit/NextcloudKit+Livephoto.swift b/Sources/NextcloudKit/NextcloudKit+Livephoto.swift index 615df69a..5c49ad86 100644 --- a/Sources/NextcloudKit/NextcloudKit+Livephoto.swift +++ b/Sources/NextcloudKit/NextcloudKit+Livephoto.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2023 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire diff --git a/Sources/NextcloudKit/NextcloudKit+Login.swift b/Sources/NextcloudKit/NextcloudKit+Login.swift index 86f9d885..df5ce0d7 100644 --- a/Sources/NextcloudKit/NextcloudKit+Login.swift +++ b/Sources/NextcloudKit/NextcloudKit+Login.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2020 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire diff --git a/Sources/NextcloudKit/NextcloudKit+NCText.swift b/Sources/NextcloudKit/NextcloudKit+NCText.swift index 2fd02e34..9d2fb097 100644 --- a/Sources/NextcloudKit/NextcloudKit+NCText.swift +++ b/Sources/NextcloudKit/NextcloudKit+NCText.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2020 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire diff --git a/Sources/NextcloudKit/NextcloudKit+PushNotification.swift b/Sources/NextcloudKit/NextcloudKit+PushNotification.swift index d7a30c9d..847093d9 100644 --- a/Sources/NextcloudKit/NextcloudKit+PushNotification.swift +++ b/Sources/NextcloudKit/NextcloudKit+PushNotification.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2020 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire diff --git a/Sources/NextcloudKit/NextcloudKit+Richdocuments.swift b/Sources/NextcloudKit/NextcloudKit+Richdocuments.swift index 372d040a..e6e25894 100644 --- a/Sources/NextcloudKit/NextcloudKit+Richdocuments.swift +++ b/Sources/NextcloudKit/NextcloudKit+Richdocuments.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2020 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire diff --git a/Sources/NextcloudKit/NextcloudKit+Search.swift b/Sources/NextcloudKit/NextcloudKit+Search.swift index 619d6201..82fecb02 100644 --- a/Sources/NextcloudKit/NextcloudKit+Search.swift +++ b/Sources/NextcloudKit/NextcloudKit+Search.swift @@ -1,7 +1,7 @@ -// -// SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2022 Henrik Storch +// SPDX-FileCopyrightText: 2023 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire diff --git a/Sources/NextcloudKit/NextcloudKit+Share.swift b/Sources/NextcloudKit/NextcloudKit+Share.swift index ea92f8e8..1b64ddbf 100644 --- a/Sources/NextcloudKit/NextcloudKit+Share.swift +++ b/Sources/NextcloudKit/NextcloudKit+Share.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2020 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire @@ -121,7 +120,7 @@ public extension NextcloudKit { guard let nkSession = nkCommonInstance.getSession(account: account), let url = nkCommonInstance.createStandardUrl(serverUrl: nkSession.urlBase, endpoint: endpoint, options: options), let headers = nkCommonInstance.getStandardHeaders(account: account, options: options) else { - return options.queue.async { completion(account, nil,nil, .urlError) } + return options.queue.async { completion(account, nil, nil, .urlError) } } let parameters = [ "search": search, @@ -275,7 +274,7 @@ public extension NextcloudKit { guard let nkSession = nkCommonInstance.getSession(account: account), let url = nkCommonInstance.createStandardUrl(serverUrl: nkSession.urlBase, endpoint: endpoint, options: options), let headers = nkCommonInstance.getStandardHeaders(account: account, options: options) else { - return options.queue.async { completion(account, nil,nil, .urlError) } + return options.queue.async { completion(account, nil, nil, .urlError) } } var parameters = [ "path": path, @@ -361,7 +360,7 @@ public extension NextcloudKit { guard let nkSession = nkCommonInstance.getSession(account: account), let url = nkCommonInstance.createStandardUrl(serverUrl: nkSession.urlBase, endpoint: endpoint, options: options), let headers = nkCommonInstance.getStandardHeaders(account: account, options: options) else { - return options.queue.async { completion(account, nil,nil, .urlError) } + return options.queue.async { completion(account, nil, nil, .urlError) } } var parameters = [ "permissions": String(permissions) diff --git a/Sources/NextcloudKit/NextcloudKit+Upload.swift b/Sources/NextcloudKit/NextcloudKit+Upload.swift index 9a1436b7..a8d3ffa7 100644 --- a/Sources/NextcloudKit/NextcloudKit+Upload.swift +++ b/Sources/NextcloudKit/NextcloudKit+Upload.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2020 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire @@ -260,4 +259,3 @@ public extension NextcloudKit { } } } - diff --git a/Sources/NextcloudKit/NextcloudKit+UserStatus.swift b/Sources/NextcloudKit/NextcloudKit+UserStatus.swift index a877b38b..72260b4f 100644 --- a/Sources/NextcloudKit/NextcloudKit+UserStatus.swift +++ b/Sources/NextcloudKit/NextcloudKit+UserStatus.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2020 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire diff --git a/Sources/NextcloudKit/NextcloudKit+WebDAV.swift b/Sources/NextcloudKit/NextcloudKit+WebDAV.swift index 01ec094b..b29c461a 100644 --- a/Sources/NextcloudKit/NextcloudKit+WebDAV.swift +++ b/Sources/NextcloudKit/NextcloudKit+WebDAV.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2020 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation import Alamofire diff --git a/Sources/NextcloudKit/NextcloudKit.h b/Sources/NextcloudKit/NextcloudKit.h index 3c8c3f84..ac61028c 100644 --- a/Sources/NextcloudKit/NextcloudKit.h +++ b/Sources/NextcloudKit/NextcloudKit.h @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2022 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// #import diff --git a/Sources/NextcloudKit/NextcloudKit.swift b/Sources/NextcloudKit/NextcloudKit.swift index 38cf690c..e6006501 100644 --- a/Sources/NextcloudKit/NextcloudKit.swift +++ b/Sources/NextcloudKit/NextcloudKit.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2019 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// #if os(macOS) import Foundation @@ -40,7 +39,7 @@ open class NextcloudKit { // MARK: - Session setup - public func setup(delegate: NextcloudKitDelegate?, memoryCapacity:Int = 30, diskCapacity:Int = 500, removeAllCachedResponses: Bool = false) { + public func setup(delegate: NextcloudKitDelegate?, memoryCapacity: Int = 30, diskCapacity: Int = 500, removeAllCachedResponses: Bool = false) { self.nkCommonInstance.delegate = delegate /// Cache URLSession diff --git a/Sources/NextcloudKit/NextcloudKitBackground.swift b/Sources/NextcloudKit/NextcloudKitBackground.swift index 03c05715..8b7da1ec 100644 --- a/Sources/NextcloudKit/NextcloudKitBackground.swift +++ b/Sources/NextcloudKit/NextcloudKitBackground.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2019 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation diff --git a/Sources/NextcloudKit/NextcloudKitSessionDelegate.swift b/Sources/NextcloudKit/NextcloudKitSessionDelegate.swift index ce0f11ae..c8b42707 100644 --- a/Sources/NextcloudKit/NextcloudKitSessionDelegate.swift +++ b/Sources/NextcloudKit/NextcloudKitSessionDelegate.swift @@ -1,7 +1,7 @@ -// -// SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2020 MarinoFaggiana +// SPDX-FileCopyrightText: 2023 Claudio Cambra // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation @@ -14,7 +14,7 @@ import Alamofire import SwiftyJSON final class NextcloudKitSessionDelegate: SessionDelegate { - public var nkCommonInstance: NKCommon? = nil + public var nkCommonInstance: NKCommon? override public init(fileManager: FileManager = .default) { super.init(fileManager: fileManager) diff --git a/Sources/NextcloudKit/Utils/FileAutoRenamer.swift b/Sources/NextcloudKit/Utils/FileAutoRenamer.swift new file mode 100644 index 00000000..ca0d508a --- /dev/null +++ b/Sources/NextcloudKit/Utils/FileAutoRenamer.swift @@ -0,0 +1,108 @@ +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2024 Milen Pivchev +// SPDX-License-Identifier: GPL-3.0-or-later + +import Foundation + +// +// AutoRenameManager.swift +// Nextcloud +// +// Created by Milen Pivchev on 09.10.24. +// Copyright © 2024 Marino Faggiana. All rights reserved. +// + +public class FileAutoRenamer { + public static let shared: FileAutoRenamer = { + let instance = FileAutoRenamer() + return instance + }() + + private var forbiddenFileNameCharacters: [String] = [] + + private var forbiddenFileNameExtensions: [String] = [] { + didSet { + forbiddenFileNameExtensions = forbiddenFileNameExtensions.map({$0.lowercased()}) + } + } + + private let replacement = "_" + + public func setup(forbiddenFileNameCharacters: [String], forbiddenFileNameExtensions: [String]) { + self.forbiddenFileNameCharacters = forbiddenFileNameCharacters + self.forbiddenFileNameExtensions = forbiddenFileNameExtensions + } + + public func rename(filename: String, isFolderPath: Bool = false) -> String { + var pathSegments = filename.split(separator: "/", omittingEmptySubsequences: false).map { String($0) } + + if isFolderPath { + forbiddenFileNameCharacters.removeAll { $0 == "/" } + } + + pathSegments = pathSegments.map { segment in + var modifiedSegment = segment + + forbiddenFileNameCharacters.forEach { forbiddenChar in + if modifiedSegment.contains(forbiddenChar) { + modifiedSegment = modifiedSegment.replacingOccurrences(of: forbiddenChar, with: replacement, options: .caseInsensitive) + } + } + + if forbiddenFileNameExtensions.contains(" ") { + modifiedSegment = modifiedSegment.trimmingCharacters(in: .whitespaces) + } + + // Replace forbidden extension, if any (ex. .part -> _part) + forbiddenFileNameExtensions.forEach { forbiddenExtension in + if modifiedSegment.lowercased().hasSuffix(forbiddenExtension) && isFullExtension(forbiddenExtension) { + let changedExtension = forbiddenExtension.replacingOccurrences(of: ".", with: replacement, options: .caseInsensitive) + modifiedSegment = modifiedSegment.replacingOccurrences(of: forbiddenExtension, with: changedExtension, options: .caseInsensitive) + } + } + + // Keep original allowed extension and add it at the end (ex file.test.txt becomes file.test) + let fileExtension = modifiedSegment.fileExtension + modifiedSegment = modifiedSegment.withRemovedFileExtension + + // Replace other forbidden extensions. Original allowed extension is ignored. + forbiddenFileNameExtensions.forEach { forbiddenExtension in + if modifiedSegment.lowercased().hasSuffix(forbiddenExtension) || modifiedSegment.lowercased().hasPrefix(forbiddenExtension) { + modifiedSegment = modifiedSegment.replacingOccurrences(of: forbiddenExtension, with: replacement, options: .caseInsensitive) + } + } + + // If there is an original allowed extension, add it back (ex file_test becomes file_test.txt) + if !fileExtension.isEmpty { + modifiedSegment.append(".\(fileExtension.lowercased())") + } + + return modifiedSegment + } + + let result = pathSegments.joined(separator: "/") + return removeNonPrintableUnicodeCharacters(convertToUTF8(result)) + } + + private func convertToUTF8(_ filename: String) -> String { + return String(data: filename.data(using: .utf8) ?? Data(), encoding: .utf8) ?? filename + } + + private func isFullExtension(_ string: String) -> Bool { + let pattern = "\\.[a-zA-Z0-9]+$" + let regex = try? NSRegularExpression(pattern: pattern, options: .caseInsensitive) + let range = NSRange(location: 0, length: string.utf16.count) + return regex?.firstMatch(in: string, options: [], range: range) != nil + } + + private func removeNonPrintableUnicodeCharacters(_ filename: String) -> String { + do { + let regex = try NSRegularExpression(pattern: "\\p{C}", options: []) + let range = NSRange(location: 0, length: filename.utf16.count) + return regex.stringByReplacingMatches(in: filename, options: [], range: range, withTemplate: "") + } catch { + print("Could not remove printable unicode characters.") + return filename + } + } +} diff --git a/Sources/NextcloudKit/Utils/FileNameValidator.swift b/Sources/NextcloudKit/Utils/FileNameValidator.swift index 3e04ab13..3c21ded5 100644 --- a/Sources/NextcloudKit/Utils/FileNameValidator.swift +++ b/Sources/NextcloudKit/Utils/FileNameValidator.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2024 Milen Pivchev // SPDX-License-Identifier: GPL-3.0-or-later -// import Foundation @@ -11,21 +10,21 @@ public class FileNameValidator { return instance }() - public private(set) var forbiddenFileNames: [String] = [] { + private var forbiddenFileNames: [String] = [] { didSet { forbiddenFileNames = forbiddenFileNames.map({$0.uppercased()}) } } - public private(set) var forbiddenFileNameBasenames: [String] = [] { + private var forbiddenFileNameBasenames: [String] = [] { didSet { forbiddenFileNameBasenames = forbiddenFileNameBasenames.map({$0.uppercased()}) } } - public private(set) var forbiddenFileNameCharacters: [String] = [] + private var forbiddenFileNameCharacters: [String] = [] - public private(set) var forbiddenFileNameExtensions: [String] = [] { + private var forbiddenFileNameExtensions: [String] = [] { didSet { forbiddenFileNameExtensions = forbiddenFileNameExtensions.map({$0.uppercased()}) } @@ -97,6 +96,10 @@ public class FileNameValidator { .allSatisfy { checkFileName(String($0)) == nil } } + public func isFileHidden(_ name: String) -> Bool { + return !name.isEmpty && name.first == "." + } + private func checkInvalidCharacters(string: String, regex: NSRegularExpression) -> NKError? { for char in string { let charAsString = String(char) diff --git a/Sources/NextcloudKit/Utils/ThreadSafeArray.swift b/Sources/NextcloudKit/Utils/ThreadSafeArray.swift index 885fcae6..1dec61d1 100644 --- a/Sources/NextcloudKit/Utils/ThreadSafeArray.swift +++ b/Sources/NextcloudKit/Utils/ThreadSafeArray.swift @@ -1,7 +1,8 @@ -// -// SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2024 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later // +// This code derived from: http://basememara.com/creating-thread-safe-arrays-in-swift/ import Foundation diff --git a/Tests/NextcloudKitIntegrationTests/BaseIntegrationXCTestCase.swift b/Tests/NextcloudKitIntegrationTests/BaseIntegrationXCTestCase.swift index 1bfb73eb..1c29b757 100644 --- a/Tests/NextcloudKitIntegrationTests/BaseIntegrationXCTestCase.swift +++ b/Tests/NextcloudKitIntegrationTests/BaseIntegrationXCTestCase.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2024 Milen Pivchev // SPDX-License-Identifier: GPL-3.0-or-later -// import XCTest @testable import NextcloudKit diff --git a/Tests/NextcloudKitIntegrationTests/FilesIntegrationTests.swift b/Tests/NextcloudKitIntegrationTests/FilesIntegrationTests.swift index 5d57580b..9607a6e9 100644 --- a/Tests/NextcloudKitIntegrationTests/FilesIntegrationTests.swift +++ b/Tests/NextcloudKitIntegrationTests/FilesIntegrationTests.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2024 Milen Pivchev // SPDX-License-Identifier: GPL-3.0-or-later -// import XCTest @testable import NextcloudKit @@ -15,43 +14,43 @@ final class FilesIntegrationTests: BaseIntegrationXCTestCase { NextcloudKit.shared.appendSession(account: account, urlBase: baseUrl, user: user, userId: userId, password: password, userAgent: "", nextcloudVersion: 0, groupIdentifier: "") - // Test creating folder - NextcloudKit.shared.createFolder(serverUrlFileName: serverUrlFileName, account: account) { account, ocId, date, error in - XCTAssertEqual(self.account, account) - - XCTAssertEqual(NKError.success.errorCode, error.errorCode) - XCTAssertEqual(NKError.success.errorDescription, error.errorDescription) - - Thread.sleep(forTimeInterval: 0.2) - - // Test reading folder, should exist - NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrlFileName, depth: "0", account: account) { account, files, data, error in - XCTAssertEqual(self.account, account) - XCTAssertEqual(NKError.success.errorCode, error.errorCode) - XCTAssertEqual(NKError.success.errorDescription, error.errorDescription) - XCTAssertEqual(files?[0].fileName, folderName) - - Thread.sleep(forTimeInterval: 0.2) - - // Test deleting folder - NextcloudKit.shared.deleteFileOrFolder(serverUrlFileName: serverUrlFileName, account: account) { account, error in - XCTAssertEqual(self.account, account) - XCTAssertEqual(NKError.success.errorCode, error.errorCode) - XCTAssertEqual(NKError.success.errorDescription, error.errorDescription) - - Thread.sleep(forTimeInterval: 0.2) - - // Test reading folder, should NOT exist - NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrlFileName, depth: "0", account: account) { account, files, data, error in - defer { expectation.fulfill() } - - XCTAssertEqual(404, error.errorCode) - XCTAssertEqual(self.account, account) - XCTAssertTrue(files?.isEmpty ?? false) - } - } - } - } +// // Test creating folder +// NextcloudKit.shared.createFolder(serverUrlFileName: serverUrlFileName, account: account) { account, ocId, date, error in +// XCTAssertEqual(self.account, account) +// +// XCTAssertEqual(NKError.success.errorCode, error.errorCode) +// XCTAssertEqual(NKError.success.errorDescription, error.errorDescription) +// +// Thread.sleep(forTimeInterval: 0.2) +// +// // Test reading folder, should exist +// NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrlFileName, depth: "0", account: account) { account, files, data, error in +// XCTAssertEqual(self.account, account) +// XCTAssertEqual(NKError.success.errorCode, error.errorCode) +// XCTAssertEqual(NKError.success.errorDescription, error.errorDescription) +// XCTAssertEqual(files?[0].fileName, folderName) +// +// Thread.sleep(forTimeInterval: 0.2) +// +// // Test deleting folder +// NextcloudKit.shared.deleteFileOrFolder(serverUrlFileName: serverUrlFileName, account: account) { account, error in +// XCTAssertEqual(self.account, account) +// XCTAssertEqual(NKError.success.errorCode, error.errorCode) +// XCTAssertEqual(NKError.success.errorDescription, error.errorDescription) +// +// Thread.sleep(forTimeInterval: 0.2) +// +// // Test reading folder, should NOT exist +// NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrlFileName, depth: "0", account: account) { account, files, data, error in +// defer { expectation.fulfill() } +// +// XCTAssertEqual(404, error.errorCode) +// XCTAssertEqual(self.account, account) +// XCTAssertTrue(files?.isEmpty ?? false) +// } +// } +// } +// } waitForExpectations(timeout: 100) } diff --git a/Tests/NextcloudKitIntegrationTests/ShareIntegrationTests.swift b/Tests/NextcloudKitIntegrationTests/ShareIntegrationTests.swift index b5c0b049..98b5572e 100644 --- a/Tests/NextcloudKitIntegrationTests/ShareIntegrationTests.swift +++ b/Tests/NextcloudKitIntegrationTests/ShareIntegrationTests.swift @@ -1,7 +1,6 @@ -// -// SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2024 Milen Pivchev // SPDX-License-Identifier: GPL-3.0-or-later -// import XCTest import Alamofire @@ -17,25 +16,25 @@ final class ShareIntegrationTests: BaseIntegrationXCTestCase { NextcloudKit.shared.appendSession(account: account, urlBase: baseUrl, user: user, userId: userId, password: password, userAgent: "", nextcloudVersion: 0, groupIdentifier: "") - NextcloudKit.shared.createFolder(serverUrlFileName: serverUrlFileName, account: account) { account, ocId, date, error in - XCTAssertEqual(self.account, account) - - XCTAssertEqual(NKError.success.errorCode, error.errorCode) - XCTAssertEqual(NKError.success.errorDescription, error.errorDescription) - - Thread.sleep(forTimeInterval: 0.2) - - let note = "Test note" - - NextcloudKit.shared.createShare(path: folderName, shareType: 0, shareWith: "nextcloud", note: note, account: "") { account, share, data, error in - defer { expectation.fulfill() } - - XCTAssertEqual(self.account, account) - XCTAssertEqual(NKError.success.errorCode, error.errorCode) - XCTAssertEqual(NKError.success.errorDescription, error.errorDescription) - XCTAssertEqual(note, share?.note) - } - } +// NextcloudKit.shared.createFolder(serverUrlFileName: serverUrlFileName, account: account) { account, ocId, date, error in +// XCTAssertEqual(self.account, account) +// +// XCTAssertEqual(NKError.success.errorCode, error.errorCode) +// XCTAssertEqual(NKError.success.errorDescription, error.errorDescription) +// +// Thread.sleep(forTimeInterval: 0.2) +// +// let note = "Test note" +// +// NextcloudKit.shared.createShare(path: folderName, shareType: 0, shareWith: "nextcloud", note: note, account: "") { account, share, data, error in +// defer { expectation.fulfill() } +// +// XCTAssertEqual(self.account, account) +// XCTAssertEqual(NKError.success.errorCode, error.errorCode) +// XCTAssertEqual(NKError.success.errorDescription, error.errorDescription) +// XCTAssertEqual(note, share?.note) +// } +// } waitForExpectations(timeout: 100) } diff --git a/Tests/NextcloudKitUnitTests/FileAutoRenamerUnitTests.swift b/Tests/NextcloudKitUnitTests/FileAutoRenamerUnitTests.swift new file mode 100644 index 00000000..27ba55cb --- /dev/null +++ b/Tests/NextcloudKitUnitTests/FileAutoRenamerUnitTests.swift @@ -0,0 +1,175 @@ +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2024 Milen Pivchev +// SPDX-License-Identifier: GPL-3.0-or-later + +import XCTest +@testable import NextcloudKit + +final class FileAutoRenamerUnitTests: XCTestCase { + let fileAutoRenamer = FileAutoRenamer.shared + + let forbiddenFilenameCharacter = ">" + let forbiddenFilenameExtension = "." + + let initialCharacters = ["<", ">", ":", "\\\\", "/", "|", "?", "*", "&"] + let initialExtensions = [" ", ",", ".", ".filepart", ".part"] + + override func setUp() { + fileAutoRenamer.setup( + forbiddenFileNameCharacters: initialCharacters, + forbiddenFileNameExtensions: initialExtensions + ) + super.setUp() + } + + func testInvalidChar() { + let filename = "File\(forbiddenFilenameCharacter)File.txt" + let result = fileAutoRenamer.rename(filename: filename) + let expectedFilename = "File_File.txt" + XCTAssertEqual(result, expectedFilename, "Expected \(expectedFilename) but got \(result)") + } + + func testInvalidExtension() { + let filename = "File\(forbiddenFilenameExtension)" + let result = fileAutoRenamer.rename(filename: filename) + let expectedFilename = "File_" + XCTAssertEqual(result, expectedFilename, "Expected \(expectedFilename) but got \(result)") + } + + func testMultipleInvalidChars() { + let filename = "File|name?<>.txt" + let result = fileAutoRenamer.rename(filename: filename) + let expectedFilename = "File_name___.txt" + XCTAssertEqual(result, expectedFilename, "Expected \(expectedFilename) but got \(result)") + } + + func testStartEndInvalidExtensions() { + let filename = " .File.part " + let result = fileAutoRenamer.rename(filename: filename) + let expectedFilename = "_File_part" + XCTAssertEqual(result, expectedFilename, "Expected \(expectedFilename) but got \(result)") + } + + func testStartEndInvalidExtensions2() { + fileAutoRenamer.setup( + forbiddenFileNameCharacters: initialCharacters, + forbiddenFileNameExtensions: [",", ".", ".filepart", ".part", " "] + ) + + let filename = " .File.part " + let result = fileAutoRenamer.rename(filename: filename) + let expectedFilename = "_File_part" + XCTAssertEqual(result, expectedFilename, "Expected \(expectedFilename) but got \(result)") + } + + func testStartEndInvalidExtensions3() { + fileAutoRenamer.setup( + forbiddenFileNameCharacters: initialCharacters, + forbiddenFileNameExtensions: [".FILEPART", ".PART", " ", ",", "."] + ) + + let filename = " .File.part " + let result = fileAutoRenamer.rename(filename: filename) + let expectedFilename = "_File_part" + XCTAssertEqual(result, expectedFilename, "Expected \(expectedFilename) but got \(result)") + } + + func testStartInvalidExtension() { + let filename = " .File.part" + let result = fileAutoRenamer.rename(filename: filename) + let expectedFilename = "_File_part" + XCTAssertEqual(result, expectedFilename, "Expected \(expectedFilename) but got \(result)") + } + + func testEndInvalidExtension() { + let filename = ".File.part " + let result = fileAutoRenamer.rename(filename: filename) + let expectedFilename = "_File_part" + XCTAssertEqual(result, expectedFilename, "Expected \(expectedFilename) but got \(result)") + } + + func testHiddenFile() { + let filename = ".Filename.txt" + let result = fileAutoRenamer.rename(filename: filename) + let expectedFilename = "_Filename.txt" + XCTAssertEqual(result, expectedFilename, "Expected \(expectedFilename) but got \(result)") + } + + func testUppercaseExtension() { + let filename = ".Filename.TXT" + let result = fileAutoRenamer.rename(filename: filename) + let expectedFilename = "_Filename.txt" + XCTAssertEqual(result, expectedFilename, "Expected \(expectedFilename) but got \(result)") + } + + func testMiddleNonPrintableChar() { + let filename = "File\u{0001}name.txt" + let result = fileAutoRenamer.rename(filename: filename) + let expectedFilename = "Filename.txt" + XCTAssertEqual(result, expectedFilename, "Expected \(expectedFilename) but got \(result)") + } + + func testStartNonPrintableChar() { + let filename = "\u{0001}Filename.txt" + let result = fileAutoRenamer.rename(filename: filename) + let expectedFilename = "Filename.txt" + XCTAssertEqual(result, expectedFilename, "Expected \(expectedFilename) but got \(result)") + } + + func testEndNonPrintableChar() { + let filename = "Filename.txt\u{0001}" + let result = fileAutoRenamer.rename(filename: filename) + let expectedFilename = "Filename.txt" + XCTAssertEqual(result, expectedFilename, "Expected \(expectedFilename) but got \(result)") + } + + func testExtensionNonPrintableChar() { + let filename = "Filename.t\u{0001}xt" + let result = fileAutoRenamer.rename(filename: filename) + let expectedFilename = "Filename.txt" + XCTAssertEqual(result, expectedFilename, "Expected \(expectedFilename) but got \(result)") + } + + func testMiddleInvalidFolderChar() { + let folderPath = "Abc/Def/kg\(forbiddenFilenameCharacter)/lmo/pp" + let result = fileAutoRenamer.rename(filename: folderPath, isFolderPath: true) + let expectedFolderName = "Abc/Def/kg_/lmo/pp" + XCTAssertEqual(result, expectedFolderName, "Expected \(expectedFolderName) but got \(result)") + } + + func testEndInvalidFolderChar() { + let folderPath = "Abc/Def/kg/lmo/pp\(forbiddenFilenameCharacter)" + let result = fileAutoRenamer.rename(filename: folderPath, isFolderPath: true) + let expectedFolderName = "Abc/Def/kg/lmo/pp_" + XCTAssertEqual(result, expectedFolderName, "Expected \(expectedFolderName) but got \(result)") + } + + func testStartInvalidFolderChar() { + let folderPath = "\(forbiddenFilenameCharacter)Abc/Def/kg/lmo/pp" + let result = fileAutoRenamer.rename(filename: folderPath, isFolderPath: true) + let expectedFolderName = "_Abc/Def/kg/lmo/pp" + XCTAssertEqual(result, expectedFolderName, "Expected \(expectedFolderName) but got \(result)") + } + + func testMixedInvalidChar() { + let filename = " File\u{0001}na\(forbiddenFilenameCharacter)me.txt " + let result = fileAutoRenamer.rename(filename: filename) + let expectedFilename = "Filena_me.txt" + XCTAssertEqual(result, expectedFilename, "Expected \(expectedFilename) but got \(result)") + } + + func testStartsWithPathSeparator() { + let folderPath = "/Abc/Def/kg/lmo/pp\(forbiddenFilenameCharacter)/File.txt/" + let result = fileAutoRenamer.rename(filename: folderPath, isFolderPath: true) + let expectedFolderName = "/Abc/Def/kg/lmo/pp_/File.txt/" + XCTAssertEqual(result, expectedFolderName, "Expected \(expectedFolderName) but got \(result)") + } + + func testStartsWithPathSeparatorAndValidFilepath() { + let folderPath = "/COm02/2569.webp" + let result = fileAutoRenamer.rename(filename: folderPath, isFolderPath: true) + let expectedFolderName = "/COm02/2569.webp" + XCTAssertEqual(result, expectedFolderName, "Expected \(expectedFolderName) but got \(result)") + } +} + diff --git a/Tests/NextcloudKitUnitTests/FileNameValidatorTests.swift b/Tests/NextcloudKitUnitTests/FileNameValidatorUnitTests.swift similarity index 74% rename from Tests/NextcloudKitUnitTests/FileNameValidatorTests.swift rename to Tests/NextcloudKitUnitTests/FileNameValidatorUnitTests.swift index 7da06a65..fab4d2ed 100644 --- a/Tests/NextcloudKitUnitTests/FileNameValidatorTests.swift +++ b/Tests/NextcloudKitUnitTests/FileNameValidatorUnitTests.swift @@ -1,12 +1,11 @@ -// -// SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2024 Milen Pivchev // SPDX-License-Identifier: GPL-3.0-or-later -// import XCTest @testable import NextcloudKit -class FileNameValidatorTests: XCTestCase { +class FileNameValidatorUnitTests: XCTestCase { let fileNameValidator = FileNameValidator.shared override func setUp() { @@ -106,46 +105,4 @@ class FileNameValidatorTests: XCTestCase { let result = fileNameValidator.checkFolderPath(folderPath) XCTAssertFalse(result) } - - func testValidFolderAndFilePaths() { - let folderPath = "validFolder" - - let result = fileNameValidator.checkFolderPath(folderPath: folderPath) - XCTAssertTrue(result) - } - - func testFolderPathWithReservedName() { - let folderPath = "CON" - - let result = fileNameValidator.checkFolderPath(folderPath: folderPath) - XCTAssertFalse(result) - } - - func testFolderPathWithInvalidCharacter() { - let folderPath = "invalid