device: Throw AlreadyInUse error if stopping an enroll during verification

When starting an enroll when verification is in progress (and vice-versa) we
emit an AlreadyInUse error, however when calling VerifyStop() during an
enrollment (and vice-versa) we just return a NoActionInProgress error, which
is not the case.

So let's be consistent and change the error type.
This commit is contained in:
Marco Trevisan (Treviño)
2020-02-11 02:09:47 +01:00
committed by Bastien Nocera
parent 154d0c0373
commit b861500a9f

View File

@ -960,6 +960,12 @@ static void fprint_device_verify_stop(FprintDevice *rdev,
dbus_g_method_return_error(context, error);
g_error_free (error);
return;
} else if (priv->current_action == ACTION_ENROLL) {
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
"Enrollment in progress");
dbus_g_method_return_error(context, error);
g_error_free (error);
return;
}
if (priv->current_cancellable) {
@ -1213,8 +1219,17 @@ static void fprint_device_enroll_stop(FprintDevice *rdev,
}
if (priv->current_action != ACTION_ENROLL) {
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_NO_ACTION_IN_PROGRESS,
"No enrollment in progress");
if (priv->current_action == ACTION_NONE) {
g_set_error (&error, FPRINT_ERROR, FPRINT_ERROR_NO_ACTION_IN_PROGRESS,
"No enrollment in progress");
} else if (priv->current_action == ACTION_VERIFY) {
g_set_error (&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
"Verification in progress");
} else if (priv->current_action == ACTION_IDENTIFY) {
g_set_error (&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
"Identification in progress");
} else
g_assert_not_reached ();
dbus_g_method_return_error(context, error);
g_error_free (error);
return;