Skip to content
Snippets Groups Projects
Commit 98973d4a authored by George Nachman's avatar George Nachman
Browse files

Add an index to lastUse on recent directories. If there are more than 1000, remove the older ones.

parent fec3c06c
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="8195" systemVersion="15A282b" minimumToolsVersion="Xcode 7.0">
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="13240" systemVersion="" minimumToolsVersion="Xcode 7.0" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="">
<entity name="CommandHistoryCommandUse" representedClassName="iTermCommandHistoryCommandUseMO" syncable="YES">
<attribute name="code" optional="YES" attributeType="Integer 32" syncable="YES"/>
<attribute name="code" optional="YES" attributeType="Integer 32" usesScalarValueType="NO" syncable="YES"/>
<attribute name="command" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="directory" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="markGuid" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="time" optional="YES" attributeType="Double" defaultValueString="0.0" syncable="YES"/>
<attribute name="time" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="NO" syncable="YES"/>
<relationship name="entry" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="CommandHistoryEntry" inverseName="uses" inverseEntity="CommandHistoryEntry" syncable="YES"/>
</entity>
<entity name="CommandHistoryEntry" representedClassName="iTermCommandHistoryEntryMO" syncable="YES">
<attribute name="command" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="matchLocation" optional="YES" transient="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
<attribute name="numberOfUses" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
<attribute name="timeOfLastUse" optional="YES" attributeType="Double" defaultValueString="0.0" syncable="YES"/>
<attribute name="matchLocation" optional="YES" transient="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
<attribute name="numberOfUses" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
<attribute name="timeOfLastUse" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="NO" syncable="YES"/>
<relationship name="remoteHost" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="HostRecord" inverseName="entries" inverseEntity="HostRecord" syncable="YES"/>
<relationship name="uses" optional="YES" toMany="YES" deletionRule="Cascade" ordered="YES" destinationEntity="CommandHistoryCommandUse" inverseName="entry" inverseEntity="CommandHistoryCommandUse" syncable="YES"/>
</entity>
Loading
Loading
@@ -22,17 +22,17 @@
<relationship name="directories" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="RecentDirectory" inverseName="remoteHost" inverseEntity="RecentDirectory" syncable="YES"/>
<relationship name="entries" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="CommandHistoryEntry" inverseName="remoteHost" inverseEntity="CommandHistoryEntry" syncable="YES"/>
</entity>
<entity name="RecentDirectory" representedClassName="iTermRecentDirectoryMO" syncable="YES">
<attribute name="lastUse" attributeType="Double" defaultValueString="0.0" syncable="YES"/>
<entity name="RecentDirectory" representedClassName="iTermRecentDirectoryMO" versionHashModifier="1" syncable="YES">
<attribute name="lastUse" attributeType="Double" defaultValueString="0.0" usesScalarValueType="NO" indexed="YES" syncable="YES"/>
<attribute name="path" attributeType="String" syncable="YES"/>
<attribute name="starred" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
<attribute name="useCount" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
<attribute name="starred" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="NO" syncable="YES"/>
<attribute name="useCount" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
<relationship name="remoteHost" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="HostRecord" inverseName="directories" inverseEntity="HostRecord" syncable="YES"/>
</entity>
<elements>
<element name="HostRecord" positionX="0" positionY="0" width="128" height="105"/>
<element name="CommandHistoryCommandUse" positionX="0" positionY="0" width="128" height="135"/>
<element name="CommandHistoryEntry" positionX="0" positionY="0" width="128" height="135"/>
<element name="HostRecord" positionX="0" positionY="0" width="128" height="105"/>
<element name="RecentDirectory" positionX="18" positionY="63" width="128" height="120"/>
</elements>
</model>
\ No newline at end of file
Loading
Loading
@@ -7221,7 +7221,7 @@
DevelopmentTeam = H7V7XYVQ7D;
};
874206460564169600CFC3F1 = {
DevelopmentTeam = CMC4EL7UVS;
DevelopmentTeam = H7V7XYVQ7D;
ProvisioningStyle = Automatic;
};
A66717851DCE36C3000CE608 = {
Loading
Loading
@@ -9017,7 +9017,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES;
DEVELOPMENT_TEAM = CMC4EL7UVS;
DEVELOPMENT_TEAM = H7V7XYVQ7D;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)",
Loading
Loading
@@ -9650,7 +9650,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES;
DEVELOPMENT_TEAM = CMC4EL7UVS;
DEVELOPMENT_TEAM = H7V7XYVQ7D;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)",
Loading
Loading
@@ -10678,7 +10678,7 @@
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = CMC4EL7UVS;
DEVELOPMENT_TEAM = H7V7XYVQ7D;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)",
Loading
Loading
@@ -10752,7 +10752,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES;
DEVELOPMENT_TEAM = CMC4EL7UVS;
DEVELOPMENT_TEAM = H7V7XYVQ7D;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)",
Loading
Loading
@@ -795,6 +795,27 @@ static const NSTimeInterval kMaxTimeToRememberDirectories = 60 * 60 * 24 * 90;
[hostRecord removeDirectoriesObject:directory];
}
 
// Only save the most recent 1000 directories
static const NSInteger iTermMaxDirectoriesToSave = 1000;
NSSortDescriptor *lastUseDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"lastUse"
ascending:NO
selector:@selector(compare:)] autorelease];
fetchRequest = [[[NSFetchRequest alloc] init] autorelease];
[fetchRequest setEntity:[NSEntityDescription entityForName:[iTermRecentDirectoryMO entityName]
inManagedObjectContext:_managedObjectContext]];
[fetchRequest setSortDescriptors:@[ lastUseDescriptor ]];
predicate = [NSPredicate predicateWithFormat:@"starred == 0"];
[fetchRequest setPredicate:predicate];
error = nil;
directories = [_managedObjectContext executeFetchRequest:fetchRequest error:&error];
if (directories.count > iTermMaxDirectoriesToSave) {
for (iTermRecentDirectoryMO *directory in [directories subarrayFromIndex:iTermMaxDirectoriesToSave]) {
iTermHostRecordMO *hostRecord = directory.remoteHost;
[hostRecord removeDirectoriesObject:directory];
}
}
error = nil;
[_managedObjectContext save:&error];
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment