From 7f2b5fe7ff4b979fdd5642268fcb56ed335278a6 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Fri, 14 May 2021 17:54:50 +0200 Subject: [PATCH] device: Avoid clearing storage when we can garbage collect If the device supports listing prints, then we can do more targeted deletes once the storage runs out. As such, do not try to clear the storage on first enroll (therefore allowing dual boot setups to work to a limited degree). --- src/device.c | 3 ++- tests/fprintd.py | 15 +++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/device.c b/src/device.c index 2d6723d..010bfc5 100644 --- a/src/device.c +++ b/src/device.c @@ -2001,7 +2001,8 @@ fprint_device_enroll_start (FprintDBusDevice *dbus_dev, priv->enroll_data = finger; priv->current_action = ACTION_ENROLL; - if (is_first_enrollment (rdev)) + if (!fp_device_has_feature (priv->dev, FP_DEVICE_FEATURE_STORAGE_LIST) && + is_first_enrollment (rdev)) { g_autoptr(GError) clear_err = NULL; diff --git a/tests/fprintd.py b/tests/fprintd.py index 2517d8e..dbea4b2 100644 --- a/tests/fprintd.py +++ b/tests/fprintd.py @@ -935,8 +935,7 @@ class FPrintdVirtualStorageDeviceTests(FPrintdVirtualStorageDeviceBaseTest): 'FP1-20201231-7-ABCDEFGH-testuser' : 'right-index-finger', 'no-metadata-new' : 'left-middle-finger', } - # Explicitly fail initial cleanup (not needed, but faster) - self.send_command('ERROR', 0) + # Device supports listing, so no initial cleanup for i, f in enrolled_prints.items(): self.enroll_print(i, f) @@ -975,8 +974,7 @@ class FPrintdVirtualStorageDeviceTests(FPrintdVirtualStorageDeviceBaseTest): self.device.Claim('(s)', 'testuser') self.assertEqual(self.get_stored_prints(), ['stored-print']) - # Explicitly fail initial cleanup (not needed, but faster) - self.send_command('ERROR', 0) + # Device supports listing, so no initial cleanup self.device.EnrollStart('(s)', 'right-thumb') self.send_image('stored-print') # During identify self.wait_for_result('enroll-stage-passed') @@ -994,8 +992,7 @@ class FPrintdVirtualStorageDeviceTests(FPrintdVirtualStorageDeviceBaseTest): self.device.Claim('(s)', 'testuser') self.assertEqual(self.get_stored_prints(), ['stored-print']) - # Explicitly fail initial cleanup (not needed, but faster) - self.send_command('ERROR', 0) + # Device supports listing, so no initial cleanup self.device.EnrollStart('(s)', 'right-thumb') self.send_image('stored-print') # During identify self.send_error(FPrint.DeviceError.PROTO) # During garbage collecting @@ -3071,8 +3068,7 @@ class FPrintdUtilsTest(FPrintdVirtualStorageDeviceBaseTest): self.set_keep_alive(True) self.device.Release() - # Open and clear storage - self.send_command('CONT') + # Open (no clear storage as list is supported) self.send_command('CONT') finger_name = self.get_finger_name(FPrint.Finger.LEFT_THUMB) @@ -3115,8 +3111,7 @@ class FPrintdUtilsTest(FPrintdVirtualStorageDeviceBaseTest): self.set_keep_alive(True) self.device.Release() - # Open and clear storage - self.send_command('CONT') + # Open (no clear storage as list is supported) self.send_command('CONT') finger_name = self.get_finger_name(FPrint.Finger.LEFT_MIDDLE)