Closed Bug 255032 Opened 20 years ago Closed 20 years ago

gnomevfs protocol handler should use info.type to check for directories

Categories

(Core :: Networking, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.8beta1

People

(Reporter: darin.moz, Assigned: darin.moz)

References

()

Details

(Keywords: fixed-aviary1.0, fixed1.7.5, Whiteboard: [patch])

Attachments

(1 file)

gnomevfs protocol handler should use info.type to check for directories.  the
current code checks info.mime_type returned from gnome_vfs_get_file_info to see
if the mime type corresponds to a directory.  however, the set of mime types
appears to be poorly specified as previous versions always returned
'x-directory/normal' for all URLs corresponding to a directoy.  Now, in newer
versions of gnome-vfs (such as the one that ships with Fedora Core 2), the mime
type is sometimes 'x-directory/normal' and other times 'x-directory/smbshare'
which breaks our current code that checks for 'x-directory/normal' :-(

we could fix this perhaps by just looking for 'x-directory/' prefixes, but
without some sort of specification saying that that is the correct thing to do,
I'm loathe to go down that path.  then i realized that gnome_vfs_get_file_info
returns an integer valued type field that gives us the information we really
want.  doh!  why didn't i use that from the start?

patch coming up...
Attached patch v1 patchSplinter Review
Status: NEW → ASSIGNED
Whiteboard: [patch]
Target Milestone: --- → mozilla1.8beta
Attachment #155703 - Flags: review?(cbiesinger)
Comment on attachment 155703 [details] [diff] [review]
v1 patch

maybe because of:
Identifies the kind of file represented by a GnomeVFSFileInfo struct. (note,
use of MIME types is preferred as this field may eventually disappear)
?
(quote from
http://developer.gnome.org/doc/API/2.0/gnome-vfs-2.0/gnome-vfs-20-gnome-vfs-fil
e-info.html)

however, while this field exists, it's probably ag ood idea to use it.

should you check that the type is actually a valid field? (by checking
info.valid_fields)
Attachment #155703 - Flags: review?(cbiesinger) → review+
> maybe because of:
> Identifies the kind of file represented by a GnomeVFSFileInfo struct. (note,
> use of MIME types is preferred as this field may eventually disappear)

yeah, maybe that is the reason.  i wish they would document the preferred
alternative.  maybe i should ask on the mailing list. 


> however, while this field exists, it's probably ag ood idea to use it.

right, my thoughts exactly.


> should you check that the type is actually a valid field? (by checking
> info.valid_fields)

good idea.
There is an interesting case where I can actually get the mime type returned to
be empty!

I don't know why this happens (it is probably a bug in the smb: protocol
handler), but if I load smb://server/share followed by smb:///, then pressing
the back button results in an error.  It seems that when reloading
smb://server/share, gnome_vfs_get_file_info returns an empty mime type!  I
haven't tried to build a reduced test case for that yet, but interestingly
enough I avoid the problem with the patch in this bug.  It seems to set
info.type properly even though it doesn't set info.mime_type!
From the Gnome VFS mailing list:

Alexander Larsson wrote:
>On Tue, 2004-08-10 at 19:58, Darin Fisher wrote:
>>/**
>> * GnomeVFSFileType:
>>...
>> * Identifies the kind of file represented by a #GnomeVFSFileInfo 
>>struct. (note,
>> * use of MIME types is preferred as this field may eventually disappear)
>> **/
>>
>>So, if use of mime types is preferred, what should I do?
>
>Thats some ancient on-crack comment. GnomeVFSFileType is not going away,
>and is in fact the right way to detect a directory.
>
>I removed the comment in cvs HEAD.
fixed-on-trunk
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Comment on attachment 155703 [details] [diff] [review]
v1 patch

This is a trivial patch to make this feature work with Gnome 2.6 and
(hopefully) later versions.  It is probably worth porting to the branches.
Attachment #155703 - Flags: approval1.7.3?
Attachment #155703 - Flags: approval-aviary?
Comment on attachment 155703 [details] [diff] [review]
v1 patch

a=mkaply for both
Attachment #155703 - Flags: approval1.7.3?
Attachment #155703 - Flags: approval1.7.3+
Attachment #155703 - Flags: approval-aviary?
Attachment #155703 - Flags: approval-aviary+
fixed1.7.3, fixed-aviary1.0
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: