From ae6c21378d231a218b266ecdecb7b54e77fea663 Mon Sep 17 00:00:00 2001 From: jrl Date: Sun, 24 Sep 2006 12:31:45 +0000 Subject: [PATCH] 2006-09-24 James Livingston * backends/rb-encoder.h: add "file access" error * lib/rb-file-helpers.c: (rb_dot_dir): * podcast/rb-podcast-manager.c: (rb_podcast_manager_download_file_info_cb): remove directory creation race condition. * backends/gstreamer/rb-encoder-gst.c: (create_parent_dirs_uri), (create_parent_dirs), (rb_encoder_gst_encode): check result of directory creation. Fixes #347743 --- ChangeLog | 13 ++++++++++ backends/gstreamer/rb-encoder-gst.c | 30 ++++++++++++++++++------ backends/rb-encoder.h | 1 + doc/reference/tmpl/rb-daap-dialog.sgml | 10 -------- doc/reference/tmpl/rb-debug.sgml | 2 ++ doc/reference/tmpl/rb-header.sgml | 1 + doc/reference/tmpl/rb-query-creator-private.sgml | 2 +- doc/reference/tmpl/rb-shell.sgml | 11 --------- doc/reference/tmpl/rb-source.sgml | 9 ------- doc/reference/tmpl/rb-statusbar.sgml | 2 +- doc/reference/tmpl/rhythmbox-unused.sgml | 26 ++++++++++++++++++++ doc/reference/tmpl/rhythmdb.sgml | 1 + lib/rb-file-helpers.c | 4 ++-- podcast/rb-podcast-manager.c | 12 +++++----- 14 files changed, 77 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index 39e28fdb..99821e67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2006-09-24 James Livingston + + * backends/rb-encoder.h: add "file access" error + + * lib/rb-file-helpers.c: (rb_dot_dir): + * podcast/rb-podcast-manager.c: + (rb_podcast_manager_download_file_info_cb): remove directory creation + race condition. + + * backends/gstreamer/rb-encoder-gst.c: (create_parent_dirs_uri), + (create_parent_dirs), (rb_encoder_gst_encode): check result of + directory creation. Fixes #347743 + 2006-09-22 Jonathan Matthew * plugins/audioscrobbler/rb-audioscrobbler.c: (*): diff --git a/backends/gstreamer/rb-encoder-gst.c b/backends/gstreamer/rb-encoder-gst.c index 3515fdff..a366b5de 100644 --- a/backends/gstreamer/rb-encoder-gst.c +++ b/backends/gstreamer/rb-encoder-gst.c @@ -877,34 +877,39 @@ transcode_track (RBEncoderGst *encoder, return TRUE; } -static void +static GnomeVFSResult create_parent_dirs_uri (GnomeVFSURI *uri) { GnomeVFSURI *parent_uri; + GnomeVFSResult result; if (gnome_vfs_uri_exists (uri)) - return; + return GNOME_VFS_OK; parent_uri = gnome_vfs_uri_get_parent (uri); - create_parent_dirs_uri (parent_uri); + result = create_parent_dirs_uri (parent_uri); gnome_vfs_uri_unref (parent_uri); + if (result != GNOME_VFS_OK) + return result; - gnome_vfs_make_directory_for_uri (uri, 0750); + return gnome_vfs_make_directory_for_uri (uri, 0750); } -static void +static GnomeVFSResult create_parent_dirs (const char *uri) { GnomeVFSURI *vfs_uri; GnomeVFSURI *parent_uri; + GnomeVFSResult result; vfs_uri = gnome_vfs_uri_new (uri); parent_uri = gnome_vfs_uri_get_parent (vfs_uri); - create_parent_dirs_uri (parent_uri); + result = create_parent_dirs_uri (parent_uri); gnome_vfs_uri_unref (parent_uri); gnome_vfs_uri_unref (vfs_uri); + return result; } static void @@ -933,6 +938,7 @@ rb_encoder_gst_encode (RBEncoder *encoder, gboolean was_raw; gboolean result; GError *error = NULL; + GnomeVFSResult vfsresult; g_return_val_if_fail (priv->pipeline == NULL, FALSE); @@ -941,7 +947,17 @@ rb_encoder_gst_encode (RBEncoder *encoder, priv->total_length = rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_DURATION); - create_parent_dirs (dest); + vfsresult = create_parent_dirs (dest); + if (vfsresult != GNOME_VFS_OK) { + error = g_error_new_literal (RB_ENCODER_ERROR, + RB_ENCODER_ERROR_FILE_ACCESS, + gnome_vfs_result_to_string (vfsresult)); + + _rb_encoder_emit_error (encoder, error); + _rb_encoder_emit_completed (encoder); + g_error_free (error); + return FALSE; + } if ((mime_type == NULL && !was_raw) || (mime_type && (strcmp (mime_type, entry_mime_type) == 0))) { result = copy_track (RB_ENCODER_GST (encoder), entry, dest, &error); diff --git a/backends/rb-encoder.h b/backends/rb-encoder.h index d9af58b1..6b4bdce1 100644 --- a/backends/rb-encoder.h +++ b/backends/rb-encoder.h @@ -38,6 +38,7 @@ enum { RB_ENCODER_ERROR_FORMAT_UNSUPPORTED, RB_ENCODER_ERROR_INTERNAL, + RB_ENCODER_ERROR_FILE_ACCESS, }; #define RB_ENCODER_ERROR rb_encoder_error_quark () diff --git a/doc/reference/tmpl/rb-daap-dialog.sgml b/doc/reference/tmpl/rb-daap-dialog.sgml index 8058f108..15a5b2fe 100644 --- a/doc/reference/tmpl/rb-daap-dialog.sgml +++ b/doc/reference/tmpl/rb-daap-dialog.sgml @@ -17,16 +17,6 @@ rb-daap-dialog - - - - - -@parent: -@name: -@Returns: - - diff --git a/doc/reference/tmpl/rb-debug.sgml b/doc/reference/tmpl/rb-debug.sgml index f5656987..3203df79 100644 --- a/doc/reference/tmpl/rb-debug.sgml +++ b/doc/reference/tmpl/rb-debug.sgml @@ -42,6 +42,8 @@ rb-debug @...: +@...: + @...: diff --git a/doc/reference/tmpl/rb-header.sgml b/doc/reference/tmpl/rb-header.sgml index 8891bd74..5bd28d21 100644 --- a/doc/reference/tmpl/rb-header.sgml +++ b/doc/reference/tmpl/rb-header.sgml @@ -39,6 +39,7 @@ rb-header @header: @entry: +@seekable: diff --git a/doc/reference/tmpl/rb-query-creator-private.sgml b/doc/reference/tmpl/rb-query-creator-private.sgml index 2a4b0243..e06fa65e 100644 --- a/doc/reference/tmpl/rb-query-creator-private.sgml +++ b/doc/reference/tmpl/rb-query-creator-private.sgml @@ -22,7 +22,7 @@ rb-query-creator-private -@constrain: +@rain: @Returns: diff --git a/doc/reference/tmpl/rb-shell.sgml b/doc/reference/tmpl/rb-shell.sgml index 8e64a05e..8dde3de8 100644 --- a/doc/reference/tmpl/rb-shell.sgml +++ b/doc/reference/tmpl/rb-shell.sgml @@ -64,23 +64,12 @@ rb-shell @Returns: - - - - - -@shell: -@uri: -@Returns: - - @shell: -@entry_type: @uri: @title: @genre: diff --git a/doc/reference/tmpl/rb-source.sgml b/doc/reference/tmpl/rb-source.sgml index 50b87398..b537754f 100644 --- a/doc/reference/tmpl/rb-source.sgml +++ b/doc/reference/tmpl/rb-source.sgml @@ -239,15 +239,6 @@ RBSource @Returns: - - - - - -@source: -@Returns: - - diff --git a/doc/reference/tmpl/rb-statusbar.sgml b/doc/reference/tmpl/rb-statusbar.sgml index 25b6c771..eada10a9 100644 --- a/doc/reference/tmpl/rb-statusbar.sgml +++ b/doc/reference/tmpl/rb-statusbar.sgml @@ -29,7 +29,7 @@ rb-statusbar @db: -@actiongroup: +@uimanager: @Returns: diff --git a/doc/reference/tmpl/rhythmbox-unused.sgml b/doc/reference/tmpl/rhythmbox-unused.sgml index 65d387c5..219700f8 100644 --- a/doc/reference/tmpl/rhythmbox-unused.sgml +++ b/doc/reference/tmpl/rhythmbox-unused.sgml @@ -522,6 +522,15 @@ @resolver: + + + + + +@parent: +@name: +@Returns: + @@ -873,6 +882,15 @@ @shell: + + + + + +@shell: +@uri: +@Returns: + @@ -935,6 +953,14 @@ @source: @Returns: + + + + + +@source: +@Returns: + diff --git a/doc/reference/tmpl/rhythmdb.sgml b/doc/reference/tmpl/rhythmdb.sgml index 2956fb57..fb5aacee 100644 --- a/doc/reference/tmpl/rhythmdb.sgml +++ b/doc/reference/tmpl/rhythmdb.sgml @@ -95,6 +95,7 @@ rhythmdb @RHYTHMDB_PROP_TYPE: +@RHYTHMDB_PROP_ENTRY_ID: @RHYTHMDB_PROP_TITLE: @RHYTHMDB_PROP_GENRE: @RHYTHMDB_PROP_ARTIST: diff --git a/lib/rb-file-helpers.c b/lib/rb-file-helpers.c index 9e213f87..ecb9f9e8 100644 --- a/lib/rb-file-helpers.c +++ b/lib/rb-file-helpers.c @@ -83,8 +83,8 @@ rb_dot_dir (void) GNOME_DOT_GNOME, "rhythmbox", NULL); - if (!g_file_test (dot_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) - mkdir (dot_dir, 0750); + if (mkdir (dot_dir, 0750) == -1) + rb_debug ("unable to create Rhythmbox's dot dir"); } return dot_dir; diff --git a/podcast/rb-podcast-manager.c b/podcast/rb-podcast-manager.c index 7e715284..36d32f40 100644 --- a/podcast/rb-podcast-manager.c +++ b/podcast/rb-podcast-manager.c @@ -664,12 +664,12 @@ rb_podcast_manager_download_file_info_cb (GnomeVFSAsyncHandle *handle, NULL); g_free (conf_dir_name); - if (!g_file_test (dir_name, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { - if (g_mkdir_with_parents (dir_name, 0750) == -1) { - g_warning ("Could not create podcast download directory %s", dir_name); - g_free (dir_name); - rb_podcast_manager_abort_download (data); - } + if (g_mkdir_with_parents (dir_name, 0750) == -1) { + rb_debug ("Could not create podcast download directory %s", dir_name); + /* FIXME: display error to user */ + g_free (dir_name); + rb_podcast_manager_abort_download (data); + return; } /* if the filename ends with the query string from the original URI, -- 2.11.4.GIT