@@ -30,7 +30,6 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele
30
30
}
31
31
}
32
32
var capabilities : Capabilities ?
33
- var itemMetadata : NKFile ?
34
33
35
34
private( set) var itemURL : URL ?
36
35
private( set) var itemServerRelativePath : String ?
@@ -117,16 +116,20 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele
117
116
presentError ( " Account data is unavailable, cannot reload data! " )
118
117
return
119
118
}
120
- itemMetadata = await fetchItemMetadata (
119
+ guard let itemMetadata = await fetchItemMetadata (
121
120
itemRelativePath: serverPathString, account: account, kit: kit
122
- )
123
- guard itemMetadata? . permissions. contains ( " R " ) == true else {
121
+ ) else {
122
+ presentError ( " Unable to retrieve file metadata... " )
123
+ return
124
+ }
125
+ guard itemMetadata. permissions. contains ( " R " ) == true else {
124
126
presentError ( " This file cannot be shared. " )
125
127
return
126
128
}
127
129
shares = await fetch (
128
130
itemIdentifier: itemIdentifier, itemRelativePath: serverPathString
129
131
)
132
+ shares. append ( Self . generateInternalShare ( for: itemMetadata) )
130
133
} catch let error {
131
134
presentError ( " Could not reload data: \( error) , will try again. " )
132
135
reattempt ( )
@@ -164,6 +167,17 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele
164
167
}
165
168
}
166
169
170
+ private static func generateInternalShare( for file: NKFile ) -> NKShare {
171
+ let internalShare = NKShare ( )
172
+ internalShare. shareType = NKShare . ShareType. internalLink. rawValue
173
+ internalShare. url = file. urlBase + " /index.php/f/ " + file. fileId
174
+ internalShare. account = file. account
175
+ internalShare. displaynameOwner = file. ownerDisplayName
176
+ internalShare. displaynameFileOwner = file. ownerDisplayName
177
+ internalShare. path = file. path
178
+ return internalShare
179
+ }
180
+
167
181
private func fetchCapabilities( ) async -> Capabilities ? {
168
182
guard let account else {
169
183
self . presentError ( " Could not fetch capabilities as account is invalid. " )
0 commit comments