Skip to content

Commit 795a19b

Browse files
committed
Update download limit only when changed by user
Signed-off-by: Milen Pivchev <[email protected]>
1 parent 038446a commit 795a19b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

iOSClient/Share/Advanced/NCShareAdvancePermission.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class NCShareAdvancePermission: UITableViewController, NCShareAdvanceFotterDeleg
5252
/// This can only be created after the share has been actually created due to its requirement of the share token provided by the server.
5353
///
5454
var downloadLimit: DownloadLimitViewModel = .unlimited
55+
var downloadLimitChanged: Bool = false
5556

5657
var shareConfig: NCShareConfig!
5758
var networking: NCShareNetworking?
@@ -260,7 +261,7 @@ class NCShareAdvancePermission: UITableViewController, NCShareAdvanceFotterDeleg
260261

261262
networking?.createShare(share, downloadLimit: self.downloadLimit)
262263
} else {
263-
networking?.updateShare(share, downloadLimit: self.downloadLimit)
264+
networking?.updateShare(share, downloadLimit: self.downloadLimit, changeDownloadLimit: downloadLimitChanged)
264265
}
265266
}
266267

@@ -273,5 +274,6 @@ class NCShareAdvancePermission: UITableViewController, NCShareAdvanceFotterDeleg
273274
extension NCShareAdvancePermission: NCShareDownloadLimitTableViewControllerDelegate {
274275
func didSetDownloadLimit(_ downloadLimit: DownloadLimitViewModel) {
275276
self.downloadLimit = downloadLimit
277+
self.downloadLimitChanged = true
276278
}
277279
}

iOSClient/Share/NCShareNetworking.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class NCShareNetworking: NSObject {
144144
self.database.addShare(account: self.metadata.account, home: home, shares: [share])
145145

146146
if shareable.hasChanges(comparedTo: share) {
147-
self.updateShare(shareable, downloadLimit: downloadLimit)
147+
self.updateShare(shareable, downloadLimit: downloadLimit, changeDownloadLimit: true)
148148
// Download limit update should happen implicitly on share update.
149149
} else {
150150
if case let .limited(limit, _) = downloadLimit,
@@ -195,7 +195,7 @@ class NCShareNetworking: NSObject {
195195
}
196196
}
197197

198-
func updateShare(_ shareable: Shareable, downloadLimit: DownloadLimitViewModel) {
198+
func updateShare(_ shareable: Shareable, downloadLimit: DownloadLimitViewModel, changeDownloadLimit: Bool = false) {
199199
NCActivityIndicator.shared.start(backgroundView: view)
200200
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
201201
Task {
@@ -216,7 +216,8 @@ class NCShareNetworking: NSObject {
216216

217217
if capabilities.fileSharingDownloadLimit,
218218
shareable.shareType == NKShare.ShareType.publicLink.rawValue,
219-
shareable.itemType == NCShareCommon.itemTypeFile {
219+
shareable.itemType == NCShareCommon.itemTypeFile,
220+
changeDownloadLimit {
220221
if case let .limited(limit, _) = downloadLimit {
221222
self.setShareDownloadLimit(limit, token: share.token)
222223
} else {

0 commit comments

Comments
 (0)