|
142 | 142 | get { self["\(key)_hash"] as? Data } |
143 | 143 | set { self["\(key)_hash"] = newValue } |
144 | 144 | } |
| 145 | + fileprivate subscript(data key: String) -> Data? { |
| 146 | + get { self["\(key)_data"] as? Data } |
| 147 | + set { self["\(key)_data"] = newValue } |
| 148 | + } |
145 | 149 | } |
146 | 150 |
|
147 | 151 | @available(macOS 13, iOS 16, tvOS 16, watchOS 9, *) |
|
178 | 182 | encryptedValues[hash: key] != hash |
179 | 183 | else { return false } |
180 | 184 |
|
181 | | - if encryptedValues[key] != nil { |
182 | | - encryptedValues.setObject(nil, forKey: key) |
| 185 | + if encryptedValues[data: key] != nil { |
| 186 | + encryptedValues[data: key] = nil |
183 | 187 | } |
184 | 188 | self[key] = newValue |
185 | 189 | encryptedValues[hash: key] = hash |
|
198 | 202 | else { return false } |
199 | 203 |
|
200 | 204 | if newValue.isSmall { |
| 205 | + let newData = Data(newValue) |
201 | 206 | guard |
202 | 207 | encryptedValues[at: key] <= userModificationTime, |
203 | | - encryptedValues[key] != newValue |
| 208 | + encryptedValues[data: key] != newData |
204 | 209 | else { return false } |
205 | 210 | if self[key] != nil { |
206 | | - self.setObject(nil, forKey: key) |
| 211 | + self[key] = nil |
| 212 | + encryptedValues[hash: key] = nil |
207 | 213 | } |
208 | | - encryptedValues[key] = newValue |
| 214 | + encryptedValues[data: key] = newData |
209 | 215 | encryptedValues[at: key] = userModificationTime |
210 | 216 | self.userModificationTime = userModificationTime |
211 | 217 | return true |
|
319 | 325 | switch Value(queryOutput: row[keyPath: keyPath]).queryBinding { |
320 | 326 | case .blob(let value): |
321 | 327 | if value.isSmall { |
322 | | - return other.encryptedValues[key] != value |
| 328 | + return other.encryptedValues[key] != Data(value) |
323 | 329 | } else if let otherHash = other.encryptedValues[hash: key] { |
324 | 330 | return otherHash != value.sha256 |
325 | 331 | } else { |
|
0 commit comments