336497 Writing Spotlight metadata files for Bonjour bookmarks generates thousands of files. Disable metadata writing for Bonjour bookmarks. Patch by smfr. r=pink a=me

This commit is contained in:
mark%moxienet.com 2006-06-02 18:11:17 +00:00
parent 84df82b58d
commit 2d8ed09f1f
3 changed files with 37 additions and 3 deletions

View File

@ -591,5 +591,15 @@ NSString* const URLLoadSuccessKey = @"url_bool";
mResolved = inResolved;
}
// We don't want to write metadata files for rendezvous bookmarks,
// as they come and go all the time, and we don't correctly clean them up.
-(void)writeBookmarksMetadataToPath:(NSString*)inPath
{
}
-(void)removeBookmarksMetadataFromPath:(NSString*)inPath
{
}
@end

View File

@ -1115,9 +1115,12 @@ static BookmarkManager* gBookmarkManager = nil;
- (void)bookmarkChanged:(NSNotification *)inNotification
{
// don't write out the bookmark file or metadata for changes in a smart container.
id item = [inNotification object];
if ([(BookmarkFolder *)[item parent] isSmartFolder])
// don't write out the bookmark file or metadata for changes in a smart container.
// we should really check to see that the bookmarks is in the tree, rather than
// just checking its parent
if (![item parent] || [(BookmarkFolder *)[item parent] isSmartFolder])
return;
unsigned int changeFlags = kBookmarkItemEverythingChangedMask;
@ -1182,9 +1185,22 @@ static BookmarkManager* gBookmarkManager = nil;
// previous version entirely.
NSString* metadataPath = [@"~/Library/Caches/Metadata" stringByExpandingTildeInPath];
[[NSFileManager defaultManager] createDirectoryAtPath:metadataPath attributes:nil];
metadataPath = [metadataPath stringByAppendingPathComponent:@"Camino"];
[[NSFileManager defaultManager] removeFileAtPath:metadataPath handler:nil];
[[NSFileManager defaultManager] createDirectoryAtPath:metadataPath attributes:nil];
// delete any existing contents
NSEnumerator* dirContentsEnum = [[[NSFileManager defaultManager] directoryContentsAtPath:metadataPath] objectEnumerator];
NSString* curFile;
while ((curFile = [dirContentsEnum nextObject]))
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSString* curFilePath = [metadataPath stringByAppendingPathComponent:curFile];
[[NSFileManager defaultManager] removeFileAtPath:curFilePath handler:nil];
[pool release];
}
// save the path for later
[mMetadataPath autorelease];
@ -1195,10 +1211,14 @@ static BookmarkManager* gBookmarkManager = nil;
BookmarkItem* curItem;
while ((curItem = [bmEnumerator nextObject]))
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
[curItem writeBookmarksMetadataToPath:mMetadataPath];
if (!(++itemCount % 100) && ![NSThread inMainThread])
usleep(10000); // 10ms to give the UI some time
[pool release];
}
}

View File

@ -247,6 +247,8 @@ static int SortByProtocolAndName(NSDictionary* item1, NSDictionary* item2, void
- (void)availableServicesChanged:(NSNotification *)note
{
[mRendezvousFolder setAccumulateUpdateNotifications:YES];
// empty the rendezvous folder
unsigned int i, count = [mRendezvousFolder count];
for (i = 0; i < count; i++)
@ -285,6 +287,8 @@ static int SortByProtocolAndName(NSDictionary* item1, NSDictionary* item2, void
}
}
[servicesArray release];
[mRendezvousFolder setAccumulateUpdateNotifications:NO];
}
- (void)serviceResolved:(NSNotification *)note