Re: Add metadata to my files for Spotlight
Re: Add metadata to my files for Spotlight
- Subject: Re: Add metadata to my files for Spotlight
- From: Lorenzo <email@hidden>
- Date: Thu, 12 May 2005 02:32:20 +0200
Thank you Ondra,
anyway, the serious part of my original argumentation was the freedom left
to developers to supply data to the spotlight indexer through the importers.
I already wrote this to the list but it seems that nobody is really
interested in this topic.
Actually the developer building his importer has the freedom to extract the
metadata from his own files using any way, for example reading the whole
file (e.g. with initWithContentsOfFile), maybe even 1GB large, just to
extract the metadata. I think that the current freedom is to guarantee
compatibility to previous version files, but since the method used involves
the performance of the file system (which invokes the importer at any
file-copy or file-duplication) I think that the developer should not be free
to decide the method to use. We are speaking about the performance of the
file system and not about the performance of a single developer's own
application. So this regards the whole Mac users community and not only that
single application users during the use of that application. Companies make
backup everyday, on any kind of file...
Think about a complex file and the way the things are today. The developer
can decide to make the importer decrypting his file, extracting the text and
the font from several objects, calculating values... and this will happen
any time that file is saved, copied or duplicated.
Think about a backup of the whole disk. It could even take a double time.
Yes, someone here told me to turn off the indexing during a backup, but I
ask to myself, after the backup is over and I turn on again the indexing,
will the new files created by the backup be indexed by Spotlight or not?
No answer. I guess "no" but I will try that by myself later.
Conclusion. I think that the developer should add the metadata to the file
"only" when the file is saved, using a standard protocol with standard and
custom keys, but with standard types only. Then stop. No importers at all.
Also Spotlight could avoid to re-index a just duplicated or just copied file
and instead it could duplicate its index simply assigning to the new record
the new pathname (actually it invokes the importer at any file-copy and
file-duplication).
This way the performance of the file system will not be affected at all.
So I suggested to provide an API that a developer can use within his
application, like
- (BOOL)addMetadata:(NSDictionary*)aDict toFile:(NSString*)pathname
This dictionary must contain standard keys like kMDItemAuthors or
kMDItemTitle and custom keys with standard types like NSString or NSArray.
No custom types.
Am I right or am I wrong? Sincerely I don't know.
Please let me know. Thanks.
Best Regards
--
Lorenzo
email: email@hidden
> From: Ondra Cada <email@hidden>
> Date: Thu, 12 May 2005 00:25:25 +0200
> To: Lorenzo <email@hidden>
> Cc: Jonathon Mah <email@hidden>, Cocoa List <email@hidden>
> Subject: Re: Add metadata to my files for Spotlight
>
> Lorenzo,
>
> On 11.5.2005, at 15:05, Lorenzo wrote:
>
>> Jonathon, what you say is what I thought indeed. But Scott
>> suggested to
>> don't do so. In that Apple sample I have found:
>>
>> pool = [[NSAutoreleasePool alloc] init];
>> tempDict = [[NSDictionary alloc]
>> initWithContentsOfFile:(NSString*)pathToFile];
>> //....
>>
>> [tempDict release];
>> [pool release];
>> return success;
>
> Don't. The pattern
>
> pool=[[NSAutoreleasePool alloc] init];
> tempDict=[NSDictionary dictionaryWith...];
> ...
> [pool release];
> return success;
>
> is as efficient as the above one, and it is *considerably* more
> failsafe (like, that it does not leak if it happens to raise an
> exception in the middle, and of course also that it is not vulnerable
> to you messing up the allocs/release pairing).
>
> There may be some point in avoiding autoreleasing in some cases, but
> self-evidently this is not one of them. My pet rule of thumb is:
> either you know darn well why you are avoiding the pool -- or, if
> not, you are making a mistake doing so.
>
>> I use this method in my applications and it always works well.
>> So, now I am confused, what do I have to do in the importer?
>
> None of the patterns is wrong per se, both would work well normally.
> The one of yours is more prone to problems though.
> ---
> Ondra Ă¢ada
> OCSoftware: email@hidden http://www.ocs.cz
> private email@hidden http://www.ocs.cz/oc
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden