@@ -716,54 +716,54 @@ - (void)clearStoredClusterDataForNodeID:(NSNumber *)nodeID
716
716
});
717
717
}
718
718
719
- - (void )clearStoredClusterDataForNodeID : (NSNumber *)nodeID endpointID : (NSNumber *)endpointID
719
+ - (void )clearStoredClusterDataForNodeID : (NSNumber *)nodeID endpointID : (NSNumber *)endpointID clusterID : ( NSNumber *) clusterID
720
720
{
721
721
dispatch_async (_storageDelegateQueue, ^{
722
- BOOL success = [self _removeEndpointFromEndpointIndex: endpointID forNodeID: nodeID];
723
- if (!success) {
724
- MTR_LOG_ERROR (" removeEndpointFromEndpointIndex for endpointID %u failed for node 0x%016llX" , endpointID.unsignedShortValue , nodeID.unsignedLongLongValue );
725
- }
726
-
727
722
NSArray <NSNumber *> * clusterIndex = [self _fetchClusterIndexForNodeID: nodeID endpointID: endpointID];
723
+ NSMutableArray <NSNumber *> * clusterIndexCopy = [clusterIndex mutableCopy ];
724
+ [clusterIndexCopy removeObject: clusterID];
728
725
729
- for (NSNumber * cluster in clusterIndex) {
730
- success = [self _deleteClusterDataForNodeID: nodeID endpointID: endpointID clusterID: cluster];
726
+ BOOL success;
727
+ if (clusterIndexCopy.count != clusterIndex.count ) {
728
+ success = [self _storeClusterIndex: clusterIndexCopy forNodeID: nodeID endpointID: endpointID];
731
729
if (!success) {
732
- MTR_LOG_ERROR (" Delete failed for clusterData for node 0x%016llX endpoint %u cluster 0x%08lX " , nodeID.unsignedLongLongValue , endpointID.unsignedShortValue , cluster. unsignedLongValue );
730
+ MTR_LOG_ERROR (" clearStoredClusterDataForNodeID: _storeClusterIndex failed for node 0x%016llX endpoint %u" , nodeID.unsignedLongLongValue , endpointID.unsignedShortValue );
733
731
}
734
732
}
735
733
736
- success = [self _deleteClusterIndexForNodeID : nodeID endpointID: endpointID];
734
+ success = [self _deleteClusterDataForNodeID : nodeID endpointID: endpointID clusterID: clusterID ];
737
735
if (!success) {
738
- MTR_LOG_ERROR (" Delete failed for clusterIndex for node 0x%016llX endpoint %u" , nodeID.unsignedLongLongValue , endpointID.unsignedShortValue );
736
+ MTR_LOG_ERROR (" clearStoredClusterDataForNodeID: _deleteClusterDataForNodeID failed for node 0x%016llX endpoint %u cluster 0x%08lX" , nodeID.unsignedLongLongValue , endpointID.unsignedShortValue , clusterID.unsignedLongValue );
737
+ return ;
739
738
}
740
739
741
- MTR_LOG (" clearStoredClusterDataForNodeID: Deleted endpoint %u for node 0x%016llX successfully" , endpointID.unsignedShortValue , nodeID.unsignedLongLongValue );
740
+ MTR_LOG (" clearStoredClusterDataForNodeID: Deleted endpoint %u cluster 0x%08lX for node 0x%016llX successfully" , endpointID.unsignedShortValue , clusterID. unsignedLongValue , nodeID.unsignedLongLongValue );
742
741
});
743
742
}
744
743
745
- - (void )clearStoredClusterDataForNodeID : (NSNumber *)nodeID endpointID : (NSNumber *)endpointID clusterID : ( NSNumber *) clusterID
744
+ - (void )clearStoredClusterDataForNodeID : (NSNumber *)nodeID endpointID : (NSNumber *)endpointID
746
745
{
747
746
dispatch_async (_storageDelegateQueue, ^{
747
+ BOOL success = [self _removeEndpointFromEndpointIndex: endpointID forNodeID: nodeID];
748
+ if (!success) {
749
+ MTR_LOG_ERROR (" removeEndpointFromEndpointIndex for endpointID %u failed for node 0x%016llX" , endpointID.unsignedShortValue , nodeID.unsignedLongLongValue );
750
+ }
751
+
748
752
NSArray <NSNumber *> * clusterIndex = [self _fetchClusterIndexForNodeID: nodeID endpointID: endpointID];
749
- NSMutableArray <NSNumber *> * clusterIndexCopy = [clusterIndex mutableCopy ];
750
- [clusterIndexCopy removeObject: clusterID];
751
753
752
- BOOL success;
753
- if (clusterIndexCopy.count != clusterIndex.count ) {
754
- success = [self _storeClusterIndex: clusterIndexCopy forNodeID: nodeID endpointID: endpointID];
754
+ for (NSNumber * cluster in clusterIndex) {
755
+ success = [self _deleteClusterDataForNodeID: nodeID endpointID: endpointID clusterID: cluster];
755
756
if (!success) {
756
- MTR_LOG_ERROR (" clearStoredClusterDataForNodeID: _storeClusterIndex failed for node 0x%016llX endpoint %u" , nodeID.unsignedLongLongValue , endpointID.unsignedShortValue );
757
+ MTR_LOG_ERROR (" Delete failed for clusterData for node 0x%016llX endpoint %u cluster 0x%08lX " , nodeID.unsignedLongLongValue , endpointID.unsignedShortValue , cluster. unsignedLongValue );
757
758
}
758
759
}
759
760
760
- success = [self _deleteClusterDataForNodeID : nodeID endpointID: endpointID clusterID: clusterID ];
761
+ success = [self _deleteClusterIndexForNodeID : nodeID endpointID: endpointID];
761
762
if (!success) {
762
- MTR_LOG_ERROR (" clearStoredClusterDataForNodeID: _deleteClusterDataForNodeID failed for node 0x%016llX endpoint %u cluster 0x%08lX" , nodeID.unsignedLongLongValue , endpointID.unsignedShortValue , clusterID.unsignedLongValue );
763
- return ;
763
+ MTR_LOG_ERROR (" Delete failed for clusterIndex for node 0x%016llX endpoint %u" , nodeID.unsignedLongLongValue , endpointID.unsignedShortValue );
764
764
}
765
765
766
- MTR_LOG (" clearStoredClusterDataForNodeID: Deleted endpoint %u cluster 0x%08lX for node 0x%016llX successfully" , endpointID.unsignedShortValue , clusterID. unsignedLongValue , nodeID.unsignedLongLongValue );
766
+ MTR_LOG (" clearStoredClusterDataForNodeID: Deleted endpoint %u for node 0x%016llX successfully" , endpointID.unsignedShortValue , nodeID.unsignedLongLongValue );
767
767
});
768
768
}
769
769
0 commit comments