[nautilus] batch-rename-dialog: fix search & replace for . and ..
- From: Alexandru-Ionut Pandelea <alexpandelea src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] batch-rename-dialog: fix search & replace for . and ..
- Date: Tue, 6 Sep 2016 09:31:44 +0000 (UTC)
commit c7fb994cef174a7a6ed4284e9f4184f750b8d711
Author: Alexandru Pandelea <alexandru pandelea gmail com>
Date: Mon Sep 5 11:40:33 2016 +0300
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
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 a8193e6..c431353 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]