Re: semantics of gnome_vfs_get_file_info_from_handle



On 3 Feb 2003, Colin Walters wrote:

> On Mon, 2003-02-03 at 10:03, Alexander Larsson wrote:
> 
> > I dunno. This is basically a uri based stat and fstat. fstat still does 
> > the same i/o that stat does. Only it doesn't have to do the pathname 
> > lookup.
> > 
> > Do you want it to keep reporting the same size as on open always too?
> 
> Actually I take my previous proposal back.  I think it would be better
> for applications to be able to just get what information the handle
> currently knows.  So the API would look like:
> 
> GnomeVFSResult	 gnome_vfs_get_known_file_info_from_handle
> 						(GnomeVFSHandle *handle,
> 						 GnomeVFSFileInfo *info);
> 
> This call would *never* do any calls to the OS or whatever; it would
> return whatever information is currently known.  Now again we can make a
> "dummy" implementation which would just return nothing, so modules which
> don't support this optimization don't have to change.  
> 
> Actually, we could implement my previous proposal on entirely top of
> this method, by getting the known fields from the handle, comparing them
> to the user's requested fields, and if the user wants something not in
> the known fields, then we fall back to the full
> gnome_vfs_get_file_info_from_handle.

I've been thinking some about this, and I'm not sure this is the right 
thing. Adding API and vfs-method functions complicates implementation and 
API and should be done very rarely.

This API would basically only be used for you to avoid doing an extra 
request on http sources when getting the mimetype, since you get that on 
open anyway. I don't see it being useful in any other way.

And since you get the info in the header when you open the stream that 
info should be pretty much up to date[1]. I think your initial proposal 
migh be better, at least for the http backend. For the file backend I'm 
not so sure, but the extra i/o is less problematic there.

Of course, when using DAV the distinction between web-server and normal 
file system becomes less distinct, and one might imagine writing to a 
handle and then using get_file_info_from_handle() to see the size of the 
file you've written. Maybe we should only return the "cached" file info if 
the handle is read-only?

[1] e.g. if someone puts up a new version of the file while you're 
downloading it, its not clear to me you will get the new file data from 
your old connection. If the server is a unix machine and the replace 
was done using e.g. "mv" you will not, since the web server keeps an open 
fd to the old (now unnamed) file.

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a lounge-singing guerilla matador living undercover at Ringling Bros. 
Circus. She's a vivacious French-Canadian research scientist with someone 
else's memories. They fight crime! 





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]