diff options
author | Alexandru Pandelea <alexandru.pandelea@gmail.com> | 2016-09-05 11:40:33 +0300 |
---|---|---|
committer | Alexandru Pandelea <alexandru.pandelea@gmail.com> | 2016-09-06 12:31:29 +0300 |
commit | c7fb994cef174a7a6ed4284e9f4184f750b8d711 (patch) | |
tree | 19d39e102f484f3ba7f0b532b5f0aab338aa024e | |
parent | 653f1079ac028b2dc2ac18c1295712a4fd5ed44b (diff) | |
download | nautilus-c7fb994cef174a7a6ed4284e9f4184f750b8d711.tar.gz |
batch-rename-dialog: fix search & replace for . and ..
In the replace mode, when "." or ".." were typed in the replace entry,
there would always pop up an error, saying that a file would have an
invalid name.
In this case, instead of checking the entry, the check must actually be
done to all the new names to see if any of those are equal to "." or
"..".
Since the new names are now used in this function, these have to be
obtained before.
https://bugzilla.gnome.org/show_bug.cgi?id=770870
-rw-r--r-- | src/nautilus-batch-rename-dialog.c | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/src/nautilus-batch-rename-dialog.c b/src/nautilus-batch-rename-dialog.c index a8193e66e..c43135311 100644 --- a/src/nautilus-batch-rename-dialog.c +++ b/src/nautilus-batch-rename-dialog.c @@ -1955,6 +1955,8 @@ update_tags (NautilusBatchRenameDialog *dialog) static gboolean have_unallowed_character (NautilusBatchRenameDialog *dialog) { + GList *names; + GString *new_name; const gchar *entry_text; gboolean have_unallowed_character_slash; gboolean have_unallowed_character_dot; @@ -1980,15 +1982,41 @@ have_unallowed_character (NautilusBatchRenameDialog *dialog) have_unallowed_character_slash = TRUE; } - if (g_strcmp0 (entry_text, ".") == 0) + if (dialog->mode == NAUTILUS_BATCH_RENAME_DIALOG_FORMAT && g_strcmp0 (entry_text, ".") == 0) { have_unallowed_character_dot = TRUE; } + else if (dialog->mode == NAUTILUS_BATCH_RENAME_DIALOG_REPLACE) + { + for (names = dialog->new_names; names != NULL; names = names->next) + { + new_name = names->data; + + if (g_strcmp0 (new_name->str, ".") == 0) + { + have_unallowed_character_dot = TRUE; + break; + } + } + } - if (g_strcmp0 (entry_text, "..") == 0) + if (dialog->mode == NAUTILUS_BATCH_RENAME_DIALOG_FORMAT && g_strcmp0 (entry_text, "..") == 0) { have_unallowed_character_dotdot = TRUE; } + else if (dialog->mode == NAUTILUS_BATCH_RENAME_DIALOG_REPLACE) + { + for (names = dialog->new_names; names != NULL; names = names->next) + { + new_name = names->data; + + if (g_strcmp0 (new_name->str, "..") == 0) + { + have_unallowed_character_dotdot = TRUE; + break; + } + } + } if (have_unallowed_character_slash) { @@ -2053,11 +2081,6 @@ update_display_text (NautilusBatchRenameDialog *dialog) dialog->duplicates = NULL; } - if (have_unallowed_character (dialog)) - { - return; - } - update_tags (dialog); if (dialog->new_names != NULL) @@ -2079,6 +2102,11 @@ update_display_text (NautilusBatchRenameDialog *dialog) dialog->new_names = batch_rename_dialog_get_new_names (dialog); dialog->checked_parents = 0; + if (have_unallowed_character (dialog)) + { + return; + } + file_names_list_has_duplicates_async (dialog, file_names_list_has_duplicates_callback, NULL); |