[gvfs] ftp: try to find hidden file/dir even when there's nothing to enumerate.
- From: Benjamin Otte <otte src gnome org>
- To: svn-commits-list gnome org
- Subject: [gvfs] ftp: try to find hidden file/dir even when there's nothing to enumerate.
- Date: Sun, 26 Apr 2009 15:21:55 -0400 (EDT)
commit fa3fa7c8e30d680678c59d5fc60305090fc8661f
Author: Andreas Henriksson <andreas fatal se>
Date: Sun Apr 26 21:19:56 2009 +0200
ftp: try to find hidden file/dir even when there's nothing to enumerate.
Don't bail out early, always try to find hidden files directories.
Fixes case when there's a symlink to a subdir of a
hidden directory which we can't enumerate. (#559142)
---
daemon/gvfsbackendftp.c | 102 ++++++++++++++++++++++++-----------------------
1 files changed, 52 insertions(+), 50 deletions(-)
diff --git a/daemon/gvfsbackendftp.c b/daemon/gvfsbackendftp.c
index e650dd0..e087839 100644
--- a/daemon/gvfsbackendftp.c
+++ b/daemon/gvfsbackendftp.c
@@ -2180,74 +2180,76 @@ create_file_info (GVfsBackendFtp *ftp, FtpConnection *conn, const char *filename
g_free (dirname);
files = enumerate_directory (ftp, conn, dir, TRUE);
- if (files == NULL)
+ if (files)
{
- g_free (dir);
- return NULL;
- }
+ iter = ftp->dir_ops->iter_new (conn);
+ for (walk = files; walk; walk = walk->next)
+ {
+ info = ftp->dir_ops->iter_process (iter,
+ conn,
+ dir,
+ file,
+ walk->data,
+ symlink);
+ if (info)
+ break;
+ }
+ ftp->dir_ops->iter_free (iter);
+ g_static_rw_lock_reader_unlock (&ftp->directory_cache_lock);
- file = ftp_filename_from_gvfs_path (conn, filename);
- iter = ftp->dir_ops->iter_new (conn);
- for (walk = files; walk; walk = walk->next)
- {
- info = ftp->dir_ops->iter_process (iter,
- conn,
- dir,
- file,
- walk->data,
- symlink);
- if (info)
- break;
+ if (info != NULL)
+ {
+ g_free (dir);
+ return info;
+ }
}
- ftp->dir_ops->iter_free (iter);
- g_static_rw_lock_reader_unlock (&ftp->directory_cache_lock);
+
+ g_free (dir);
/* try to find hidden file/directory */
- if (info == NULL)
+ file = ftp_filename_from_gvfs_path (conn, filename);
+
+ if (ftp_connection_try_cd (conn, file))
{
- if (ftp_connection_try_cd (conn, file))
- {
- char *tmp;
+ char *tmp;
- info = g_file_info_new ();
+ info = g_file_info_new ();
- tmp = g_path_get_basename (filename);
- g_file_info_set_name (info, tmp);
- g_free (tmp);
+ tmp = g_path_get_basename (filename);
+ g_file_info_set_name (info, tmp);
+ g_free (tmp);
- gvfs_file_info_populate_default (info, filename, G_FILE_TYPE_DIRECTORY);
+ gvfs_file_info_populate_default (info, filename, G_FILE_TYPE_DIRECTORY);
- g_file_info_set_is_hidden (info, TRUE);
- }
- else if (ftp_connection_send (conn, 0, "SIZE %s", file))
- {
- char *tmp;
+ g_file_info_set_is_hidden (info, TRUE);
+ }
+ else if (ftp_connection_send (conn, 0, "SIZE %s", file))
+ {
+ char *tmp;
- info = g_file_info_new ();
+ info = g_file_info_new ();
- tmp = g_path_get_basename (filename);
- g_file_info_set_name (info, tmp);
- g_free (tmp);
+ tmp = g_path_get_basename (filename);
+ g_file_info_set_name (info, tmp);
+ g_free (tmp);
- gvfs_file_info_populate_default (info, filename, G_FILE_TYPE_REGULAR);
+ gvfs_file_info_populate_default (info, filename, G_FILE_TYPE_REGULAR);
- g_file_info_set_size (info, strtoul (conn->read_buffer+4, NULL, 0));
+ g_file_info_set_size (info, strtoul (conn->read_buffer+4, NULL, 0));
- g_file_info_set_is_hidden (info, TRUE);
- }
- else
- {
- /* clear error from ftp_connection_send() in else if line above */
- ftp_connection_clear_error (conn);
+ g_file_info_set_is_hidden (info, TRUE);
+ }
+ else
+ {
+ /* clear error from ftp_connection_send() in else if line above */
+ ftp_connection_clear_error (conn);
- /* note that there might still be a file/directory, we just have
- * no way to figure this out (in particular on ftp servers that
- * don't support SIZE.
- * If you have ways to improve file detection, patches are welcome. */
- }
+ /* note that there might still be a file/directory, we just have
+ * no way to figure this out (in particular on ftp servers that
+ * don't support SIZE.
+ * If you have ways to improve file detection, patches are welcome. */
}
- g_free (dir);
g_free (file);
return info;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]