From 14c9f88e9c8988e18429872cd3f2684e01301a5d Mon Sep 17 00:00:00 2001 From: Vivek Dasmohapatra Date: Thu, 22 Aug 2013 19:44:29 +0100 Subject: [PATCH] trivial-httpd: Handle the autoexit case when the docroot is a symlink --- src/ostree/ot-builtin-trivial-httpd.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ostree/ot-builtin-trivial-httpd.c b/src/ostree/ot-builtin-trivial-httpd.c index 3c8fff9b..9607f4db 100644 --- a/src/ostree/ot-builtin-trivial-httpd.c +++ b/src/ostree/ot-builtin-trivial-httpd.c @@ -342,7 +342,23 @@ ostree_builtin_trivial_httpd (int argc, char **argv, GFile *repo_path, GCancella app->running = TRUE; if (opt_autoexit) { - dirmon = g_file_monitor_directory (app->root, 0, cancellable, error); + gboolean is_symlink = FALSE; + gs_unref_object GFileInfo *info = NULL; + + info = g_file_query_info (app->root, + G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK, + G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, + cancellable, error); + if (!info) + goto out; + + is_symlink = g_file_info_get_is_symlink (info); + + if (is_symlink) + dirmon = g_file_monitor_file (app->root, 0, cancellable, error); + else + dirmon = g_file_monitor_directory (app->root, 0, cancellable, error); + if (!dirmon) goto out; g_signal_connect (dirmon, "changed", G_CALLBACK (on_dir_changed), app);