[gnome-disk-utility] Use ensure_unused() before doing a write-benchmark on a device
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility] Use ensure_unused() before doing a write-benchmark on a device
- Date: Mon, 26 Nov 2012 19:25:47 +0000 (UTC)
commit f8decc497b1ab8b46313a14e9532a83343e3d132
Author: David Zeuthen <zeuthen gmail com>
Date: Mon Nov 26 14:05:02 2012 -0500
Use ensure_unused() before doing a write-benchmark on a device
This way users won't have to unmount/lock whatever is on a device
before doing a write-benchmark.
Signed-off-by: David Zeuthen <zeuthen gmail com>
src/disks/gdubenchmarkdialog.c | 55 +++++++++++++++++++++++++++++++--------
1 files changed, 43 insertions(+), 12 deletions(-)
---
diff --git a/src/disks/gdubenchmarkdialog.c b/src/disks/gdubenchmarkdialog.c
index e01ec05..d5673c4 100644
--- a/src/disks/gdubenchmarkdialog.c
+++ b/src/disks/gdubenchmarkdialog.c
@@ -1444,6 +1444,36 @@ abort_benchmark (DialogData *data)
}
static void
+start_benchmark2 (DialogData *data)
+{
+ data->bm_in_progress = TRUE;
+ data->bm_state = BM_STATE_OPENING_DEVICE;
+ g_clear_error (&data->bm_error);
+ g_array_set_size (data->bm_read_samples, 0);
+ g_array_set_size (data->bm_write_samples, 0);
+ g_array_set_size (data->bm_access_time_samples, 0);
+ data->bm_time_benchmarked_usec = 0;
+ g_cancellable_reset (data->bm_cancellable);
+
+ data->bm_thread = g_thread_new ("benchmark-thread",
+ benchmark_thread,
+ dialog_data_ref (data));
+}
+
+static void
+ensure_unused_cb (GduWindow *window,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ DialogData *data = user_data;
+ if (gdu_window_ensure_unused_finish (window, res, NULL))
+ {
+ start_benchmark2 (data);
+ }
+ dialog_data_unref (data);
+}
+
+static void
start_benchmark (DialogData *data)
{
GtkWidget *dialog;
@@ -1497,18 +1527,19 @@ start_benchmark (DialogData *data)
//g_print ("do_write=%d\n", data->bm_do_write);
//g_print ("num_access_samples=%d\n", data->bm_num_access_samples);
- data->bm_in_progress = TRUE;
- data->bm_state = BM_STATE_OPENING_DEVICE;
- g_clear_error (&data->bm_error);
- g_array_set_size (data->bm_read_samples, 0);
- g_array_set_size (data->bm_write_samples, 0);
- g_array_set_size (data->bm_access_time_samples, 0);
- data->bm_time_benchmarked_usec = 0;
- g_cancellable_reset (data->bm_cancellable);
-
- data->bm_thread = g_thread_new ("benchmark-thread",
- benchmark_thread,
- dialog_data_ref (data));
+ if (data->bm_do_write)
+ {
+ /* ensure the device is unused (e.g. unmounted) before formatting it... */
+ gdu_window_ensure_unused (data->window,
+ data->object,
+ (GAsyncReadyCallback) ensure_unused_cb,
+ NULL, /* GCancellable */
+ dialog_data_ref (data));
+ }
+ else
+ {
+ start_benchmark2 (data);
+ }
out:
gtk_widget_destroy (dialog);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]