[Pkg-privacy-commits] [nautilus-wipe] 28/224: Correct handling of empty file lists.
Ulrike Uhlig
u-guest at moszumanska.debian.org
Thu Jul 7 19:45:31 UTC 2016
This is an automated email from the git hooks/post-receive script.
u-guest pushed a commit to branch master
in repository nautilus-wipe.
commit 9f97ba47acb2ad037d8d93f026ecaf642c2e6976
Author: Colomban Wendling <ban at herbesfolles.org>
Date: Sat Feb 20 22:12:02 2010 +0100
Correct handling of empty file lists.
Throw an error if an operation is launched without files to work on.
---
nautilus-srm/delete-operation.c | 7 +++++++
nautilus-srm/fill-operation.c | 40 ++++++++++++++++++++++++----------------
2 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/nautilus-srm/delete-operation.c b/nautilus-srm/delete-operation.c
index 1ea08cd..fdde8ca 100644
--- a/nautilus-srm/delete-operation.c
+++ b/nautilus-srm/delete-operation.c
@@ -53,6 +53,7 @@ nautilus_srm_delete_operation (GList *files,
{
gboolean success = TRUE;
GsdDeleteOperation *operation;
+ guint n_files = 0;
operation = gsd_delete_operation_new ();
for (; success && files; files = g_list_next (files)) {
@@ -72,6 +73,12 @@ nautilus_srm_delete_operation (GList *files,
}
g_free (path);
g_object_unref (file);
+ n_files ++;
+ }
+ if (success && n_files < 1) {
+ /* FIXME: use correct error quark and code */
+ g_set_error (error, 0, 0, "Nothing to do!");
+ success = FALSE;
}
/* if file addition succeeded, try to launch operation */
if (success) {
diff --git a/nautilus-srm/fill-operation.c b/nautilus-srm/fill-operation.c
index 4781964..f568a4a 100644
--- a/nautilus-srm/fill-operation.c
+++ b/nautilus-srm/fill-operation.c
@@ -301,23 +301,31 @@ nautilus_srm_fill_operation (GList *directories,
{
gboolean success = TRUE;
struct FillOperationData *opdata;
+ GList *dirs;
- opdata = g_slice_alloc (sizeof *opdata);
- opdata->dir = filter_dir_list (directories);
- opdata->finished_handler = (FillFinishedFunc)finished_handler;
- opdata->progress_handler = (FillProgressFunc)progress_handler;
- opdata->cbdata = data;
- opdata->n_op = g_list_length (opdata->dir);
- opdata->n_op_done = 0;
- opdata->operation = gsd_fill_operation_new ();
- opdata->progress_hid = g_signal_connect (opdata->operation, "progress",
- G_CALLBACK (nautilus_srm_fill_progress_handler), opdata);
- opdata->finished_hid = g_signal_connect (opdata->operation, "finished",
- G_CALLBACK (nautilus_srm_fill_finished_handler), opdata);
- /* launches the operation */
- success = do_sfill_operation (opdata, error);
- if (! success) {
- nautilus_srm_fill_cleanup (opdata);
+ dirs = filter_dir_list (directories);
+ if (! dirs) {
+ /* FIXME: use correct error quark and code */
+ g_set_error (error, 0, 0, "Nothing to do!");
+ success = FALSE;
+ } else {
+ opdata = g_slice_alloc (sizeof *opdata);
+ opdata->dir = dirs;
+ opdata->finished_handler = (FillFinishedFunc)finished_handler;
+ opdata->progress_handler = (FillProgressFunc)progress_handler;
+ opdata->cbdata = data;
+ opdata->n_op = g_list_length (opdata->dir);
+ opdata->n_op_done = 0;
+ opdata->operation = gsd_fill_operation_new ();
+ opdata->progress_hid = g_signal_connect (opdata->operation, "progress",
+ G_CALLBACK (nautilus_srm_fill_progress_handler), opdata);
+ opdata->finished_hid = g_signal_connect (opdata->operation, "finished",
+ G_CALLBACK (nautilus_srm_fill_finished_handler), opdata);
+ /* launches the operation */
+ success = do_sfill_operation (opdata, error);
+ if (! success) {
+ nautilus_srm_fill_cleanup (opdata);
+ }
}
return success;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/nautilus-wipe.git
More information about the Pkg-privacy-commits
mailing list