Skip to content

Commit

Permalink
- OCClassSettings: thin registered metadata in low memory configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-schwarz committed Nov 28, 2024
1 parent a3c1563 commit e57ad35
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion ownCloudSDK/Settings/OCClassSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,37 @@ - (void)registerDefaults:(NSDictionary<OCClassSettingsKey, id> *)defaults metada
_registeredMetaDataCollectionsByIdentifier[identifier] = registeredMetaDataCollections;
}

[registeredMetaDataCollections addObject:metaData];
if (OCPlatform.current.memoryConfiguration == OCPlatformMemoryConfigurationMinimum)
{
@autoreleasepool {
NSMutableDictionary<OCClassSettingsKey,OCClassSettingsMetadata> *filteredCollection = [NSMutableDictionary new];

for (OCClassSettingsKey settingsKey in metaData)
{
OCClassSettingsMetadata settingsMetadata = metaData[settingsKey];
id mdType = settingsMetadata[OCClassSettingsMetadataKeyType];
id mdPossibleKeys = settingsMetadata[OCClassSettingsMetadataKeyPossibleKeys];

if ((mdType != nil) || (mdPossibleKeys != nil))
{
NSMutableDictionary<OCClassSettingsMetadataKey,id> *filteredMetadata = [NSMutableDictionary new];
filteredMetadata[OCClassSettingsMetadataKeyType] = mdType;
filteredMetadata[OCClassSettingsMetadataKeyPossibleKeys] = mdPossibleKeys;

filteredCollection[settingsKey] = [[NSDictionary alloc] initWithDictionary:filteredMetadata];
}
}

if (filteredCollection.count > 0)
{
[registeredMetaDataCollections addObject:[[NSDictionary alloc] initWithDictionary:filteredCollection]];
}
}
}
else
{
[registeredMetaDataCollections addObject:metaData];
}
}

[self clearSourceCache];
Expand Down

0 comments on commit e57ad35

Please sign in to comment.