Don't compare un-persisted properties of NextcloudItemMetadataTable in isInSameRemoteState, fixing constant updating of metadatas

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-03-11 02:30:54 +01:00
parent d528adf345
commit 882e58aa64
No known key found for this signature in database
GPG key ID: C839200C384636B0
2 changed files with 6 additions and 6 deletions

View file

@ -155,7 +155,7 @@ class NextcloudFilesDatabaseManager : NSObject {
if let existingMetadata = existingMetadatas.first(where: { $0.ocId == updatedMetadata.ocId }) {
if existingMetadata.status == NextcloudItemMetadataTable.Status.normal.rawValue &&
!existingMetadata.isInSameRemoteState(updatedMetadata) {
!existingMetadata.isInSameDatabaseStoreableRemoteState(updatedMetadata) {
returningUpdatedMetadatas.append(NextcloudItemMetadataTable(value: updatedMetadata))
databaseToWriteTo.add(updatedMetadata, update: .all)
@ -169,7 +169,9 @@ class NextcloudFilesDatabaseManager : NSObject {
, updatedMetadata.ocId, updatedMetadata.fileName, updatedMetadata.etag)
} else {
NSLog("""
Skipping metadata update as received metadata status is same as existing:
Skipping metadata update as received metadata status is same as existing,
or metadata is currently being downloaded/uploaded:
ocID: %@,
fileName: %@,
etag: %@

View file

@ -54,7 +54,7 @@ class NextcloudItemMetadataTable: Object {
return false
}
func isInSameRemoteState(_ comparingMetadata: NextcloudItemMetadataTable) -> Bool {
func isInSameDatabaseStoreableRemoteState(_ comparingMetadata: NextcloudItemMetadataTable) -> Bool {
return comparingMetadata.etag == self.etag &&
comparingMetadata.fileNameView == self.fileNameView &&
comparingMetadata.date == self.date &&
@ -62,8 +62,6 @@ class NextcloudItemMetadataTable: Object {
comparingMetadata.hasPreview == self.hasPreview &&
comparingMetadata.note == self.note &&
comparingMetadata.lock == self.lock &&
comparingMetadata.shareType == self.shareType &&
comparingMetadata.sharePermissionsCloudMesh == self.sharePermissionsCloudMesh &&
comparingMetadata.sharePermissionsCollaborationServices == self.sharePermissionsCollaborationServices &&
comparingMetadata.favorite == self.favorite
}
@ -119,7 +117,7 @@ class NextcloudItemMetadataTable: Object {
@Persisted var sessionSelector = ""
@Persisted var sessionTaskIdentifier: Int = 0
@Persisted var sharePermissionsCollaborationServices: Int = 0
let sharePermissionsCloudMesh = List<String>()
let sharePermissionsCloudMesh = List<String>() // TODO: Find a way to compare these in remote state check
let shareType = List<Int>()
@Persisted var size: Int64 = 0
@Persisted var status: Int = 0