Skip to content

Commit d6de920

Browse files
authored
Merge pull request #6650 from nextcloud/backport/6648/stable-3.13-fileprovider
[stable-3.13-fileprovider] Fix possible issues with item metadata acquisition required for macOS VFS file sharing
2 parents 1b146bb + 531d8ee commit d6de920

9 files changed

+77
-42
lines changed

shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift

+6-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class DocumentActionViewController: FPUIActionExtensionViewController {
3434
override func prepare(
3535
forAction actionIdentifier: String, itemIdentifiers: [NSFileProviderItemIdentifier]
3636
) {
37-
Logger.actionViewController.info("Preparing for action: \(actionIdentifier)")
37+
Logger.actionViewController.info("Preparing action: \(actionIdentifier, privacy: .public)")
3838

3939
if actionIdentifier == "com.nextcloud.desktopclient.FileProviderUIExt.ShareAction" {
4040
prepare(childViewController: ShareViewController(itemIdentifiers))
@@ -43,7 +43,11 @@ class DocumentActionViewController: FPUIActionExtensionViewController {
4343
}
4444

4545
override func prepare(forError error: Error) {
46-
Logger.actionViewController.info("Preparing for error: \(error.localizedDescription)")
46+
Logger.actionViewController.info(
47+
"""
48+
Preparing for error: \(error.localizedDescription, privacy: .public)
49+
"""
50+
)
4751
}
4852

4953
override public func loadView() {

shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/FileProviderUIExt.entitlements

+4
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@
88
<array>
99
<string>$(OC_SOCKETAPI_TEAM_IDENTIFIER_PREFIX)$(OC_APPLICATION_REV_DOMAIN)</string>
1010
</array>
11+
<key>com.apple.security.network.client</key>
12+
<true/>
13+
<key>com.apple.security.network.server</key>
14+
<true/>
1115
</dict>
1216
</plist>

shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/FileProviderUIExtRelease.entitlements

-16
This file was deleted.

shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Info.plist

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>CFBundleName</key>
6+
<string>$(PRODUCT_NAME)</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>$(OC_APPLICATION_NAME) File Provider UI Extension</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(OC_APPLICATION_REV_DOMAIN).$(PRODUCT_NAME)</string>
511
<key>NSExtension</key>
612
<dict>
713
<key>NSExtensionFileProviderActions</key>
@@ -15,10 +21,10 @@
1521
<string>Share options</string>
1622
</dict>
1723
</array>
18-
<key>NSExtensionPrincipalClass</key>
19-
<string>$(PRODUCT_MODULE_NAME).DocumentActionViewController</string>
2024
<key>NSExtensionPointIdentifier</key>
2125
<string>com.apple.fileprovider-actionsui</string>
26+
<key>NSExtensionPrincipalClass</key>
27+
<string>$(PRODUCT_MODULE_NAME).DocumentActionViewController</string>
2228
</dict>
2329
</dict>
2430
</plist>

shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareController.swift

+33-9
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,18 @@ class ShareController: ObservableObject {
4242
) { account, share, data, error in
4343
defer { continuation.resume(returning: error) }
4444
guard error == .success else {
45-
Logger.shareController.error("Error creating link share: \(error)")
45+
Logger.shareController.error(
46+
"""
47+
Error creating link share: \(error.errorDescription, privacy: .public)
48+
"""
49+
)
4650
return
4751
}
4852
}
4953
} else {
5054
guard let shareWith = shareWith else {
5155
let errorString = "No recipient for share!"
52-
Logger.shareController.error("\(errorString)")
56+
Logger.shareController.error("\(errorString, privacy: .public)")
5357
let error = NKError(statusCode: 0, fallbackDescription: errorString)
5458
continuation.resume(returning: error)
5559
return
@@ -66,7 +70,11 @@ class ShareController: ObservableObject {
6670
) { account, share, data, error in
6771
defer { continuation.resume(returning: error) }
6872
guard error == .success else {
69-
Logger.shareController.error("Error creating share: \(error)")
73+
Logger.shareController.error(
74+
"""
75+
Error creating share: \(error.errorDescription, privacy: .public)
76+
"""
77+
)
7078
return
7179
}
7280
}
@@ -90,7 +98,7 @@ class ShareController: ObservableObject {
9098
attributes: String? = nil,
9199
options: NKRequestOptions = NKRequestOptions()
92100
) async -> NKError? {
93-
Logger.shareController.info("Saving share: \(self.share.url)")
101+
Logger.shareController.info("Saving share: \(self.share.url, privacy: .public)")
94102
return await withCheckedContinuation { continuation in
95103
kit.updateShare(
96104
idShare: share.idShare,
@@ -104,10 +112,18 @@ class ShareController: ObservableObject {
104112
attributes: attributes,
105113
options: options
106114
) { account, share, data, error in
107-
Logger.shareController.info("Received update response: \(share?.url ?? "")")
115+
Logger.shareController.info(
116+
"""
117+
Received update response: \(share?.url ?? "", privacy: .public)
118+
"""
119+
)
108120
defer { continuation.resume(returning: error) }
109121
guard error == .success, let share = share else {
110-
Logger.shareController.error("Error updating save: \(error.errorDescription)")
122+
Logger.shareController.error(
123+
"""
124+
Error updating save: \(error.errorDescription, privacy: .public)
125+
"""
126+
)
111127
return
112128
}
113129
self.share = share
@@ -116,13 +132,21 @@ class ShareController: ObservableObject {
116132
}
117133

118134
func delete() async -> NKError? {
119-
Logger.shareController.info("Deleting share: \(self.share.url)")
135+
Logger.shareController.info("Deleting share: \(self.share.url, privacy: .public)")
120136
return await withCheckedContinuation { continuation in
121137
kit.deleteShare(idShare: share.idShare) { account, error in
122-
Logger.shareController.info("Received delete response: \(self.share.url)")
138+
Logger.shareController.info(
139+
"""
140+
Received delete response: \(self.share.url, privacy: .public)
141+
"""
142+
)
123143
defer { continuation.resume(returning: error) }
124144
guard error == .success else {
125-
Logger.shareController.error("Error deleting save: \(error.errorDescription)")
145+
Logger.shareController.error(
146+
"""
147+
Error deleting save: \(error.errorDescription, privacy: .public)
148+
"""
149+
)
126150
return
127151
}
128152
}

shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class ShareOptionsView: NSView {
7171
}
7272
var createMode = false {
7373
didSet {
74-
Logger.shareOptionsView.info("Create mode set: \(self.createMode)")
74+
Logger.shareOptionsView.info("Create mode set: \(self.createMode, privacy: .public)")
7575
shareTypePicker.isHidden = !createMode
7676
shareRecipientTextField.isHidden = !createMode
7777
labelTextField.isHidden = createMode // Cannot set label on create API call
@@ -259,10 +259,10 @@ class ShareOptionsView: NSView {
259259
let itemServerRelativePath = dataSource.itemServerRelativePath
260260
else {
261261
Logger.shareOptionsView.error("Cannot create new share due to missing data.")
262-
Logger.shareOptionsView.error("dataSource: \(self.dataSource)")
263-
Logger.shareOptionsView.error("kit: \(self.kit)")
262+
Logger.shareOptionsView.error("dataSource: \(self.dataSource, privacy: .public)")
263+
Logger.shareOptionsView.error("kit: \(self.kit, privacy: .public)")
264264
Logger.shareOptionsView.error(
265-
"path: \(self.dataSource?.itemServerRelativePath ?? "")"
265+
"path: \(self.dataSource?.itemServerRelativePath ?? "", privacy: .public)"
266266
)
267267
return
268268
}

shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele
9999
account = convertedAccount
100100
await sharesTableView?.deselectAll(self)
101101
capabilities = await fetchCapabilities()
102+
guard capabilities != nil else { return }
102103
guard capabilities?.filesSharing?.apiEnabled == true else {
103104
presentError("Server does not support shares.")
104105
return

shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift

+18-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate {
4747
return
4848
}
4949

50+
Logger.shareViewController.info(
51+
"""
52+
Instantiated with itemIdentifiers:
53+
\(itemIdentifiers.map { $0.rawValue }, privacy: .public)
54+
"""
55+
)
56+
5057
Task {
5158
await processItemIdentifier(firstItem)
5259
}
@@ -72,14 +79,19 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate {
7279

7380
do {
7481
let itemUrl = try await manager.getUserVisibleURL(for: itemIdentifier)
82+
guard itemUrl.startAccessingSecurityScopedResource() else {
83+
Logger.shareViewController.error("Could not access scoped resource for item url!")
84+
return
85+
}
7586
await updateDisplay(itemUrl: itemUrl)
7687
shareDataSource.uiDelegate = self
7788
shareDataSource.sharesTableView = tableView
7889
shareDataSource.loadItem(url: itemUrl)
7990
optionsView.dataSource = shareDataSource
91+
itemUrl.stopAccessingSecurityScopedResource()
8092
} catch let error {
8193
let errorString = "Error processing item: \(error)"
82-
Logger.shareViewController.error("\(errorString)")
94+
Logger.shareViewController.error("\(errorString, privacy: .public)")
8395
fileNameLabel.stringValue = "Unknown item"
8496
descriptionLabel.stringValue = errorString
8597
}
@@ -99,7 +111,11 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate {
99111
let fileThumbnail = await withCheckedContinuation { continuation in
100112
generator.generateRepresentations(for: request) { thumbnail, type, error in
101113
if thumbnail == nil || error != nil {
102-
Logger.shareViewController.error("Could not get thumbnail: \(error)")
114+
Logger.shareViewController.error(
115+
"""
116+
Could not get thumbnail: \(error, privacy: .public)
117+
"""
118+
)
103119
}
104120
continuation.resume(returning: thumbnail)
105121
}

shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj

+3-7
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@
157157
536EFBF6295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderSocketLineProcessor.swift; sourceTree = "<group>"; };
158158
5374FD432B95EE1400C78D54 /* ShareController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareController.swift; sourceTree = "<group>"; };
159159
5376307C2B85E2ED0026BFAB /* Logger+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Logger+Extensions.swift"; sourceTree = "<group>"; };
160-
5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = FileProviderUIExt.entitlements; sourceTree = "<group>"; };
161160
537630902B85F4980026BFAB /* ShareViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ShareViewController.xib; sourceTree = "<group>"; };
162161
537630922B85F4B00026BFAB /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; };
163162
537630942B860D560026BFAB /* FPUIExtensionServiceSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FPUIExtensionServiceSource.swift; sourceTree = "<group>"; };
@@ -181,7 +180,7 @@
181180
53D666602B70C9A70042C03D /* FileProviderConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderConfig.swift; sourceTree = "<group>"; };
182181
53ED472F29C9CE0B00795DB1 /* FileProviderExtension+ClientInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileProviderExtension+ClientInterface.swift"; sourceTree = "<group>"; };
183182
53FE144F2B8E0658006C4193 /* ShareTableViewDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareTableViewDataSource.swift; sourceTree = "<group>"; };
184-
53FE14572B8E3A7C006C4193 /* FileProviderUIExtRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = FileProviderUIExtRelease.entitlements; sourceTree = "<group>"; };
183+
53FE14572B8E3A7C006C4193 /* FileProviderUIExt.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = FileProviderUIExt.entitlements; sourceTree = "<group>"; };
185184
53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareTableItemView.swift; sourceTree = "<group>"; };
186185
53FE145A2B8F1305006C4193 /* NKShare+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NKShare+Extensions.swift"; sourceTree = "<group>"; };
187186
53FE14642B8F6700006C4193 /* ShareViewDataSourceUIDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewDataSourceUIDelegate.swift; sourceTree = "<group>"; };
@@ -329,8 +328,7 @@
329328
537630922B85F4B00026BFAB /* ShareViewController.swift */,
330329
537630902B85F4980026BFAB /* ShareViewController.xib */,
331330
53FE14642B8F6700006C4193 /* ShareViewDataSourceUIDelegate.swift */,
332-
5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */,
333-
53FE14572B8E3A7C006C4193 /* FileProviderUIExtRelease.entitlements */,
331+
53FE14572B8E3A7C006C4193 /* FileProviderUIExt.entitlements */,
334332
53B979852B84C81F002DA742 /* Info.plist */,
335333
);
336334
path = FileProviderUIExt;
@@ -1023,7 +1021,6 @@
10231021
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
10241022
GENERATE_INFOPLIST_FILE = YES;
10251023
INFOPLIST_FILE = FileProviderUIExt/Info.plist;
1026-
INFOPLIST_KEY_CFBundleDisplayName = FileProviderUIExt;
10271024
INFOPLIST_KEY_NSHumanReadableCopyright = "";
10281025
INFOPLIST_OUTPUT_FORMAT = "same-as-input";
10291026
INFOPLIST_PREPROCESS = NO;
@@ -1070,7 +1067,7 @@
10701067
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
10711068
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
10721069
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
1073-
CODE_SIGN_ENTITLEMENTS = FileProviderUIExt/FileProviderUIExtRelease.entitlements;
1070+
CODE_SIGN_ENTITLEMENTS = FileProviderUIExt/FileProviderUIExt.entitlements;
10741071
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
10751072
CODE_SIGN_STYLE = Manual;
10761073
COPY_PHASE_STRIP = NO;
@@ -1084,7 +1081,6 @@
10841081
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
10851082
GENERATE_INFOPLIST_FILE = YES;
10861083
INFOPLIST_FILE = FileProviderUIExt/Info.plist;
1087-
INFOPLIST_KEY_CFBundleDisplayName = FileProviderUIExt;
10881084
INFOPLIST_KEY_NSHumanReadableCopyright = "";
10891085
INFOPLIST_OUTPUT_FORMAT = "same-as-input";
10901086
INFOPLIST_PREPROCESS = NO;

0 commit comments

Comments
 (0)