[rhythmbox/uri-is-descendant: 2/2] use rb_uri_is_descendant in a few places
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox/uri-is-descendant: 2/2] use rb_uri_is_descendant in a few places
- Date: Fri, 26 Mar 2021 03:55:46 +0000 (UTC)
commit 8b7309cdef0091f67bea3678544aa5d58d7f2e4d
Author: Jonathan Matthew <jonathan d14n org>
Date: Tue Mar 23 23:04:25 2021 +1000
use rb_uri_is_descendant in a few places
This is better than the string prefix checks we had before as it ensures
that the end of the ancestor URI is also the end of a path component of
the descendant.
plugins/generic-player/rb-generic-player-source.c | 4 ++--
rhythmdb/rhythmdb-monitor.c | 2 +-
widgets/rb-import-dialog.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/plugins/generic-player/rb-generic-player-source.c
b/plugins/generic-player/rb-generic-player-source.c
index 03e59916c..b8b0ff68e 100644
--- a/plugins/generic-player/rb-generic-player-source.c
+++ b/plugins/generic-player/rb-generic-player-source.c
@@ -683,7 +683,7 @@ default_uri_from_playlist_uri (RBGenericPlayerSource *source, const char *uri)
char *full_uri;
mount_uri = rb_generic_player_source_get_mount_path (source);
- if (g_str_has_prefix (uri, mount_uri)) {
+ if (rb_uri_is_descendant (uri, mount_uri)) {
return g_strdup (uri);
}
@@ -704,7 +704,7 @@ default_uri_to_playlist_uri (RBGenericPlayerSource *source, const char *uri, Tot
case TOTEM_PL_PARSER_IRIVER_PLA:
/* we need absolute paths within the device filesystem for this format */
mount_uri = rb_generic_player_source_get_mount_path (source);
- if (g_str_has_prefix (uri, mount_uri) == FALSE) {
+ if (rb_uri_is_descendant (uri, mount_uri) == FALSE) {
rb_debug ("uri %s is not under device mount uri %s", uri, mount_uri);
return NULL;
}
diff --git a/rhythmdb/rhythmdb-monitor.c b/rhythmdb/rhythmdb-monitor.c
index a59600288..dbb0f1bfe 100644
--- a/rhythmdb/rhythmdb-monitor.c
+++ b/rhythmdb/rhythmdb-monitor.c
@@ -280,7 +280,7 @@ rhythmdb_directory_change_cb (GFileMonitor *monitor,
/* ignore new files outside of the library locations */
for (i = 0; db->priv->library_locations[i] != NULL; i++) {
- if (g_str_has_prefix (canon_uri, db->priv->library_locations[i])) {
+ if (rb_uri_is_descendant (canon_uri, db->priv->library_locations[i])) {
in_library = TRUE;
break;
}
diff --git a/widgets/rb-import-dialog.c b/widgets/rb-import-dialog.c
index 86c36823f..dfa7b2995 100644
--- a/widgets/rb-import-dialog.c
+++ b/widgets/rb-import-dialog.c
@@ -431,7 +431,7 @@ current_folder_changed_cb (GtkFileChooser *chooser, RBImportDialog *dialog)
locations = g_settings_get_strv (settings, "locations");
gtk_widget_set_sensitive (dialog->priv->copy_check, TRUE);
for (i = 0; locations[i] != NULL; i++) {
- if (g_str_has_prefix (uri, locations[i])) {
+ if ((g_strcmp0 (uri, locations[i]) == 0) || rb_uri_is_descendant (uri, locations[i])) {
gtk_widget_set_sensitive (dialog->priv->copy_check, FALSE);
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]