Ensure errors are always publicly displayed in unified logging of File Provider

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-03-14 21:14:09 +01:00
Родитель 545fe6d56e
Коммит 3082850e68
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: C839200C384636B0
5 изменённых файлов: 26 добавлений и 26 удалений

Просмотреть файл

@ -63,7 +63,7 @@ class NextcloudFilesDatabaseManager : NSObject {
_ = try Realm()
Logger.ncFilesDatabase.info("Successfully started Realm db for FileProviderExt")
} catch let error as NSError {
Logger.ncFilesDatabase.error("Error opening Realm db: \(error)")
Logger.ncFilesDatabase.error("Error opening Realm db: \(error, privacy: .public)")
}
super.init()
@ -199,7 +199,7 @@ class NextcloudFilesDatabaseManager : NSObject {
completionHandler(metadatasFromUpdate.newMetadatas, metadatasFromUpdate.updatedMetadatas, deletedMetadatas)
}
} catch let error {
Logger.ncFilesDatabase.error("Could not update any item metadatas, received error: \(error)")
Logger.ncFilesDatabase.error("Could not update any item metadatas, received error: \(error, privacy: .public)")
completionHandler(nil, nil, nil)
}
}
@ -221,7 +221,7 @@ class NextcloudFilesDatabaseManager : NSObject {
Logger.ncFilesDatabase.debug("Updated status for item metadata. \(itemMetadataLogString)")
}
} catch let error {
Logger.ncFilesDatabase.error("Could not update status for item metadata with \(itemMetadataLogString), received error: \(error)")
Logger.ncFilesDatabase.error("Could not update status for item metadata with \(itemMetadataLogString), received error: \(error, privacy: .public)")
}
if result != nil {
@ -241,7 +241,7 @@ class NextcloudFilesDatabaseManager : NSObject {
Logger.ncFilesDatabase.debug("Added item metadata. \(itemMetadataLogString)")
}
} catch let error {
Logger.ncFilesDatabase.error("Could not add item metadata. \(itemMetadataLogString), received error: \(error)")
Logger.ncFilesDatabase.error("Could not add item metadata. \(itemMetadataLogString), received error: \(error, privacy: .public)")
}
}
@ -256,7 +256,7 @@ class NextcloudFilesDatabaseManager : NSObject {
database.delete(results)
}
} catch let error {
Logger.ncFilesDatabase.error("Could not delete item metadata with ocId: \(ocId), received error: \(error)")
Logger.ncFilesDatabase.error("Could not delete item metadata with ocId: \(ocId), received error: \(error, privacy: .public)")
}
}
@ -282,7 +282,7 @@ class NextcloudFilesDatabaseManager : NSObject {
Logger.ncFilesDatabase.debug("Renamed item \(oldFileName) to \(newFileName), moved from serverUrl: \(oldServerUrl) to serverUrl: \(newServerUrl)")
}
} catch let error {
Logger.ncFilesDatabase.error("Could not rename filename of item metadata with ocID: \(ocId) to proposed name \(newFileName) at proposed serverUrl \(newServerUrl), received error: \(error)")
Logger.ncFilesDatabase.error("Could not rename filename of item metadata with ocID: \(ocId) to proposed name \(newFileName) at proposed serverUrl \(newServerUrl), received error: \(error, privacy: .public)")
}
}
@ -455,7 +455,7 @@ class NextcloudFilesDatabaseManager : NSObject {
Logger.ncFilesDatabase.debug("Added new directory metadata. \(directoryMetadataLogString)")
}
} catch let error {
Logger.ncFilesDatabase.error("Could not add new directory metadata. \(directoryMetadataLogString), received error: \(error)")
Logger.ncFilesDatabase.error("Could not add new directory metadata. \(directoryMetadataLogString), received error: \(error, privacy: .public)")
}
}
@ -482,7 +482,7 @@ class NextcloudFilesDatabaseManager : NSObject {
database.delete(results)
}
} catch let error {
Logger.ncFilesDatabase.error("Could not delete root directory metadata in recursive delete. \(directoryMetadataLogString), received error: \(error)")
Logger.ncFilesDatabase.error("Could not delete root directory metadata in recursive delete. \(directoryMetadataLogString), received error: \(error, privacy: .public)")
}
}
@ -530,7 +530,7 @@ class NextcloudFilesDatabaseManager : NSObject {
}
}
} catch let error {
Logger.ncFilesDatabase.error("Could not rename directory metadata with ocId: \(ocId) to new serverUrl: \(newServerUrl), received error: \(error)")
Logger.ncFilesDatabase.error("Could not rename directory metadata with ocId: \(ocId) to new serverUrl: \(newServerUrl), received error: \(error, privacy: .public)")
}
}
@ -563,7 +563,7 @@ class NextcloudFilesDatabaseManager : NSObject {
Logger.ncFilesDatabase.debug("Added local file metadata from item metadata. \(itemMetadataLogString)")
}
} catch let error {
Logger.ncFilesDatabase.error("Could not add local file metadata from item metadata. \(itemMetadataLogString), received error: \(error)")
Logger.ncFilesDatabase.error("Could not add local file metadata from item metadata. \(itemMetadataLogString), received error: \(error, privacy: .public)")
}
}
@ -576,7 +576,7 @@ class NextcloudFilesDatabaseManager : NSObject {
database.delete(results)
}
} catch let error {
Logger.ncFilesDatabase.error("Could not delete local file metadata with ocId: \(ocId), received error: \(error)")
Logger.ncFilesDatabase.error("Could not delete local file metadata with ocId: \(ocId), received error: \(error, privacy: .public)")
}
}

Просмотреть файл

@ -107,7 +107,7 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
FileProviderEnumerator.readServerUrl(directoryMetadata.serverUrl, ncAccount: ncAccount, ncKit: ncKit) { metadatas, _, _, _, readError in
guard readError == nil else {
Logger.enumeration.error("Finishing enumeration of working set directory \(directoryMetadata.serverUrl) with error \(readError!)")
Logger.enumeration.error("Finishing enumeration of working set directory \(directoryMetadata.serverUrl) with error \(readError!, privacy: .public)")
let nkError = NKError(error: readError!)
if nkError.isUnauthenticatedError || nkError.isCouldntConnectError {
@ -168,7 +168,7 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
FileProviderEnumerator.readServerUrl(serverUrl, ncAccount: ncAccount, ncKit: ncKit) { _, _, _, _, readError in
guard readError == nil else {
Logger.enumeration.error("Finishing enumeration for user: \(self.ncAccount.ncKitAccount) with serverUrl: \(self.serverUrl) with error \(readError!)")
Logger.enumeration.error("Finishing enumeration for user: \(self.ncAccount.ncKitAccount) with serverUrl: \(self.serverUrl) with error \(readError!, privacy: .public)")
let nkReadError = NKError(error: readError!)
observer.finishEnumeratingWithError(nkReadError.toFileProviderError())
@ -249,7 +249,7 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
// handling below or from the completeChangesObserver
FileProviderEnumerator.readServerUrl(serverUrl, ncAccount: ncAccount, ncKit: ncKit, stopAtMatchingEtags: true) { _, newMetadatas, updatedMetadatas, deletedMetadatas, readError in
guard readError == nil else {
Logger.enumeration.error("Finishing enumeration of changes for user: \(self.ncAccount.ncKitAccount) with serverUrl: \(self.serverUrl) with error: \(readError!)")
Logger.enumeration.error("Finishing enumeration of changes for user: \(self.ncAccount.ncKitAccount) with serverUrl: \(self.serverUrl) with error: \(readError!, privacy: .public)")
let nkReadError = NKError(error: readError!)
let fpError = nkReadError.toFileProviderError()
@ -419,7 +419,7 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
Logger.enumeration.debug("About to read: \(directoryMetadata.serverUrl)")
FileProviderEnumerator.readServerUrl(directoryMetadata.serverUrl, ncAccount: ncAccount, ncKit: ncKit, stopAtMatchingEtags: true) { _, newMetadatas, updatedMetadatas, deletedMetadatas, readError in
guard readError == nil else {
Logger.enumeration.error("Finishing enumeration of changes at \(directoryMetadata.serverUrl) with \(readError!)")
Logger.enumeration.error("Finishing enumeration of changes at \(directoryMetadata.serverUrl) with \(readError!, privacy: .public)")
let nkReadError = NKError(error: readError!)
if nkReadError.isNotFoundError {
@ -500,7 +500,7 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
ncKit.readFileOrFolder(serverUrlFileName: serverUrl, depth: "0", showHiddenFiles: true) { account, files, _, error in
guard error == .success else {
Logger.enumeration.error("0 depth readFileOrFolder of url: \(serverUrl) did not complete successfully, received error: \(error)")
Logger.enumeration.error("0 depth readFileOrFolder of url: \(serverUrl) did not complete successfully, received error: \(error, privacy: .public)")
completionHandler(nil, nil, nil, nil, error.error)
return
}
@ -538,7 +538,7 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
ncKit.readFileOrFolder(serverUrlFileName: serverUrl, depth: "1", showHiddenFiles: true) { account, files, _, error in
guard error == .success else {
Logger.enumeration.error("1 depth readFileOrFolder of url: \(serverUrl) did not complete successfully, received error: \(error)")
Logger.enumeration.error("1 depth readFileOrFolder of url: \(serverUrl) did not complete successfully, received error: \(error, privacy: .public)")
completionHandler(nil, nil, nil, nil, error.error)
return
}

Просмотреть файл

@ -195,7 +195,7 @@ class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension, NKComm
}
}
} catch let error {
Logger.fileProviderExtension.error("Could not find local path for file \(metadata.fileName), received error: \(error)")
Logger.fileProviderExtension.error("Could not find local path for file \(metadata.fileName), received error: \(error, privacy: .public)")
completionHandler(nil, nil, NSFileProviderError(.cannotSynchronize))
}
@ -259,7 +259,7 @@ class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension, NKComm
if itemTemplateIsFolder {
self.ncKit.createFolder(serverUrlFileName: newServerUrlFileName) { account, ocId, _, error in
guard error == .success else {
Logger.fileTransfer.error("Could not create new folder with name: \(itemTemplate.filename), received error: \(error)")
Logger.fileTransfer.error("Could not create new folder with name: \(itemTemplate.filename), received error: \(error, privacy: .public)")
completionHandler(itemTemplate, [], false, error.toFileProviderError())
return
}
@ -267,7 +267,7 @@ class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension, NKComm
// Read contents after creation
self.ncKit.readFileOrFolder(serverUrlFileName: newServerUrlFileName, depth: "0", showHiddenFiles: true) { account, files, _, error in
guard error == .success else {
Logger.fileTransfer.error("Could not read new folder with name: \(itemTemplate.filename), received error: \(error)")
Logger.fileTransfer.error("Could not read new folder with name: \(itemTemplate.filename), received error: \(error, privacy: .public)")
return
}
@ -303,7 +303,7 @@ class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension, NKComm
self.outstandingSessionTasks.removeValue(forKey: newServerUrlFileName)
guard error == .success, let ocId = ocId/*, size == itemTemplate.documentSize as! Int64*/ else {
Logger.fileTransfer.error("Could not upload item with filename: \(itemTemplate.filename), received error: \(error)")
Logger.fileTransfer.error("Could not upload item with filename: \(itemTemplate.filename), received error: \(error, privacy: .public)")
completionHandler(itemTemplate, [], false, error.toFileProviderError())
return
}
@ -409,7 +409,7 @@ class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension, NKComm
serverUrlFileNameDestination: newServerUrlFileName,
overwrite: false) { account, error in
guard error == .success else {
Logger.fileTransfer.error("Could not move file or folder: \(oldServerUrlFileName) to \(newServerUrlFileName), received error: \(error)")
Logger.fileTransfer.error("Could not move file or folder: \(oldServerUrlFileName) to \(newServerUrlFileName), received error: \(error, privacy: .public)")
renameError = error.toFileProviderError()
dispatchGroup.leave()
return
@ -478,7 +478,7 @@ class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension, NKComm
self.outstandingSessionTasks.removeValue(forKey: newServerUrlFileName)
guard error == .success, let ocId = ocId/*, size == itemTemplate.documentSize as! Int64*/ else {
Logger.fileTransfer.error("Could not upload item \(item.itemIdentifier.rawValue) with filename: \(item.filename), received error: \(error)")
Logger.fileTransfer.error("Could not upload item \(item.itemIdentifier.rawValue) with filename: \(item.filename), received error: \(error, privacy: .public)")
completionHandler(modifiedItem, [], false, error.toFileProviderError())
return
}
@ -540,7 +540,7 @@ class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension, NKComm
self.ncKit.deleteFileOrFolder(serverUrlFileName: serverFileNameUrl) { account, error in
guard error == .success else {
Logger.fileTransfer.error("Could not delete item with ocId \(identifier.rawValue) at \(serverFileNameUrl), received error: \(error)")
Logger.fileTransfer.error("Could not delete item with ocId \(identifier.rawValue) at \(serverFileNameUrl), received error: \(error, privacy: .public)")
completionHandler(error.toFileProviderError())
return
}

Просмотреть файл

@ -43,7 +43,7 @@ class FileProviderMaterialisedEnumerationObserver : NSObject, NSFileProviderEnum
}
func finishEnumeratingWithError(_ error: Error) {
Logger.materialisedFileHandling.error("Ran into error when enumerating materialised items: \(error). Handling items enumerated so far")
Logger.materialisedFileHandling.error("Ran into error when enumerating materialised items: \(error, privacy: .public). Handling items enumerated so far")
FileProviderMaterialisedEnumerationObserver.handleEnumeratedItems(self.allEnumeratedItemIds,
account: self.ncKitAccount,
completionHandler: self.completionHandler)

Просмотреть файл

@ -86,6 +86,6 @@ func createFileOrDirectoryLocally(metadata: NextcloudItemMetadataTable) {
try localPathForNCFile(itemMetadata: metadata)
}
} catch let error {
Logger.enumeration.error("Could not create NC file or directory locally, received error: \(error)")
Logger.enumeration.error("Could not create NC file or directory locally, received error: \(error, privacy: .public)")
}
}