om_utils_get_parent_path_from_uri adds extraneous slash at the end of returned path

Bug #140446 reported by Leszek Koltunski
2
Affects Status Importance Assigned to Milestone
OBEX FTP Client for GNOME-VFS
New
Undecided
Unassigned

Bug Description

function om_utils_get_parent_path_from_uri() from src/om-utils.c contains a call to

    parent_path = g_strconcat (tmp, "/", NULL);

thus, it will always return a path with an extra slash at the end.

Now, I dont know what is the reason for this, maybe it is needed somewhere, but this behavior breaks optimization in function
om_get_folder_listing() from obex-method.c : this function checks if we already have folder listing in our cache with the following if

   if (path && conn->current_dir && strcmp (path, conn->current_dir) == 0 && conn->current_listing != NULL )
      {
      // return already cached listing
      }

The problem is that often, variable 'path' has been filled up by a call to om_utils_get_parent_path_from_uri(),
and 'conn->current_dir' has been filled up by a call to om_utils_get_path_from_uri(). Or the other way around.

The first function adds extraneous slash, the second doesnt, thus check 'strcmp(path,conn->current_dir)==0' often fails even though
the paths are really the same, for example '/' and '//', or '/C:' and '/C:/'.

Revision history for this message
Leszek Koltunski (leszek-3miasto) wrote :

It appears that the only possible reason why om_utils_get_parent_path_from_uri() adds the slash is in function
om_utils_get_path_list_from_uri() from src/om-utils() : it was probably feared that the call

            path_start = strstr (new_path, cur_dir);

( where new_path might have been returned by om_utils_get_parent_path_from_uri() ) would not have the slash in between.

This reason is bogus, because om_utils_get_parent_path_from_uri() essentially does nothing else but calls om_utils_get_path_from_uri().

Now we have 2 possibilities:

1) either om_utils_get_path_from_uri() always returns path with a slash at the end
( my debugging suggests that this is the case ) in which case we have no problem

2) or it does not, in which case adding an extra slash in om_utils_get_parent_path_from_uri()
does not help anyway, because 'new_path' might have been returned by om_utils_get_path_from_uri()
in which case we still have a problem.

Conclusion: remove the call to g_strconcat(), win efficiency.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.