@@ -114,23 +114,20 @@ class NCShareNetworking: NSObject {
114114 }
115115 }
116116
117- func createShare( _ template: Shareable , downloadLimit: DownloadLimitViewModel ) {
118- // NOTE: Permissions don't work for creating with file drop!
119- // https://github.com/nextcloud/server/issues/17504
120-
117+ func createShare( _ shareable: Shareable , downloadLimit: DownloadLimitViewModel ) {
121118 NCActivityIndicator . shared. start ( backgroundView: view)
122119 let filenamePath = utilityFileSystem. getFileNamePath ( metadata. fileName, serverUrl: metadata. serverUrl, session: session)
123120 let capabilities = NCNetworking . shared. capabilities [ self . metadata. account] ?? NKCapabilities . Capabilities ( )
124121
125122 NextcloudKit . shared. createShare ( path: filenamePath,
126- shareType: template . shareType,
127- shareWith: template . shareWith,
123+ shareType: shareable . shareType,
124+ shareWith: shareable . shareWith,
128125 publicUpload: false ,
129- note: template . note,
126+ note: shareable . note,
130127 hideDownload: false ,
131- password: template . password,
132- permissions: template . permissions,
133- attributes: template . attributes,
128+ password: shareable . password,
129+ permissions: shareable . permissions,
130+ attributes: shareable . attributes,
134131 account: metadata. account) { task in
135132 Task {
136133 let identifier = await NCNetworking . shared. networkingTasks. createIdentifier ( account: self . metadata. account,
@@ -142,16 +139,18 @@ class NCShareNetworking: NSObject {
142139 NCActivityIndicator . shared. stop ( )
143140
144141 if error == . success, let share = share {
145- template . idShare = share. idShare
142+ shareable . idShare = share. idShare
146143 let home = self . utilityFileSystem. getHomeServer ( session: self . session)
147144 self . database. addShare ( account: self . metadata. account, home: home, shares: [ share] )
148145
149- if template . hasChanges ( comparedTo: share) {
150- self . updateShare ( template , downloadLimit: downloadLimit)
146+ if shareable . hasChanges ( comparedTo: share) {
147+ self . updateShare ( shareable , downloadLimit: downloadLimit)
151148 // Download limit update should happen implicitly on share update.
152149 } else {
153150 if case let . limited( limit, _) = downloadLimit,
154- capabilities. fileSharingDownloadLimit {
151+ capabilities. fileSharingDownloadLimit,
152+ shareable. shareType == NCShareCommon . shareTypeLink,
153+ shareable. itemType == NCShareCommon . itemTypeFile {
155154 self . setShareDownloadLimit ( limit, token: share. token)
156155 }
157156 }
@@ -196,12 +195,12 @@ class NCShareNetworking: NSObject {
196195 }
197196 }
198197
199- func updateShare( _ option : Shareable , downloadLimit: DownloadLimitViewModel ) {
198+ func updateShare( _ shareable : Shareable , downloadLimit: DownloadLimitViewModel ) {
200199 NCActivityIndicator . shared. start ( backgroundView: view)
201- NextcloudKit . shared. updateShare ( idShare: option . idShare, password: option . password, expireDate: option . formattedDateString, permissions: option . permissions, note: option . note, label: option . label, hideDownload: option . hideDownload, attributes: option . attributes, account: metadata. account) { task in
200+ NextcloudKit . shared. updateShare ( idShare: shareable . idShare, password: shareable . password, expireDate: shareable . formattedDateString, permissions: shareable . permissions, note: shareable . note, label: shareable . label, hideDownload: shareable . hideDownload, attributes: shareable . attributes, account: metadata. account) { task in
202201 Task {
203202 let identifier = await NCNetworking . shared. networkingTasks. createIdentifier ( account: self . metadata. account,
204- path: " _ \( option . idShare) " ,
203+ path: " _ \( shareable . idShare) " ,
205204 name: " updateShare " )
206205 await NCNetworking . shared. networkingTasks. track ( identifier: identifier, task: task)
207206 }
@@ -215,7 +214,9 @@ class NCShareNetworking: NSObject {
215214 self . database. addShare ( account: self . metadata. account, home: home, shares: [ share] )
216215 self . delegate? . readShareCompleted ( )
217216
218- if capabilities. fileSharingDownloadLimit {
217+ if capabilities. fileSharingDownloadLimit,
218+ shareable. shareType == NCShareCommon . shareTypeLink,
219+ shareable. itemType == NCShareCommon . itemTypeFile {
219220 if case let . limited( limit, _) = downloadLimit {
220221 self . setShareDownloadLimit ( limit, token: share. token)
221222 } else {
@@ -230,7 +231,7 @@ class NCShareNetworking: NSObject {
230231 }
231232 } else {
232233 NCContentPresenter ( ) . showError ( error: error)
233- self . delegate? . updateShareWithError ( idShare: option . idShare)
234+ self . delegate? . updateShareWithError ( idShare: shareable . idShare)
234235 }
235236 }
236237 }
@@ -264,7 +265,7 @@ class NCShareNetworking: NSObject {
264265 func removeShareDownloadLimit( token: String ) {
265266 let capabilities = NCNetworking . shared. capabilities [ self . metadata. account] ?? NKCapabilities . Capabilities ( )
266267
267- if !capabilities. fileSharingDownloadLimit {
268+ if !capabilities. fileSharingDownloadLimit || token . isEmpty {
268269 return
269270 }
270271
@@ -289,7 +290,7 @@ class NCShareNetworking: NSObject {
289290 func setShareDownloadLimit( _ limit: Int , token: String ) {
290291 let capabilities = NCNetworking . shared. capabilities [ self . metadata. account] ?? NKCapabilities . Capabilities ( )
291292
292- if !capabilities. fileSharingDownloadLimit {
293+ if !capabilities. fileSharingDownloadLimit || token . isEmpty {
293294 return
294295 }
295296
0 commit comments