From be19246648ad3c25b6b91719021efa02286dcc40 Mon Sep 17 00:00:00 2001 From: James Manuel Date: Tue, 19 May 2026 22:50:27 +0200 Subject: [PATCH] fix: :bug: guard against negative nc:lock-timeout when computing lockTimeOut MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When files_lock is configured with infinite timeout (-1 minutes), the server sends nc:lock-timeout=-60. Without the guard, lockTimeOut would be set to lockTime minus 60 seconds — a date in the past — causing clients to display the lock as already expired. Only compute lockTimeOut when the value is positive; leave it nil for infinite locks (zero or negative sentinel values). Co-Authored-By: Claude Sonnet 4.6 Signed-off-by: James Manuel --- Sources/NextcloudKit/Models/NKDataFileXML.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/NextcloudKit/Models/NKDataFileXML.swift b/Sources/NextcloudKit/Models/NKDataFileXML.swift index 1d334e5c..c723efec 100644 --- a/Sources/NextcloudKit/Models/NKDataFileXML.swift +++ b/Sources/NextcloudKit/Models/NKDataFileXML.swift @@ -472,7 +472,7 @@ public class NKDataFileXML: NSObject { if let lockTime = propstat["d:prop", "nc:lock-time"].int { file.lockTime = Date(timeIntervalSince1970: TimeInterval(lockTime)) } - if let lockTimeOut = propstat["d:prop", "nc:lock-timeout"].int { + if let lockTimeOut = propstat["d:prop", "nc:lock-timeout"].int, lockTimeOut > 0 { file.lockTimeOut = file.lockTime?.addingTimeInterval(TimeInterval(lockTimeOut)) }