homed: rescan /home/ in more occasions automatically
When unregistering a home there's a chance this "reveals" another home by the same name in /home/, hence immediately schedule a rescan, the same way we already schedule it in on remove. Also, drop the conditionalization when scheduling a rescan during remove, for the same reasons: a remove might reveal another home, and we cannot check for that ahead of time. Trying to check is kinda a pointless optimization anyway, since this is not a frequent operation and rescanning is not the end of the world.
This commit is contained in:
@@ -915,8 +915,7 @@ static void home_remove_finish(Home *h, int ret, UserRecord *hr) {
|
||||
* partitions like USB sticks, or so). Sometimes these storage locations are among those we normally
|
||||
* automatically discover in /home or in udev. When such a home is deleted let's hence issue a rescan
|
||||
* after completion, so that "unfixated" entries are rediscovered. */
|
||||
if (!IN_SET(user_record_test_image_path(h->record), USER_TEST_UNDEFINED, USER_TEST_ABSENT))
|
||||
manager_enqueue_rescan(m);
|
||||
(void) manager_enqueue_rescan(m);
|
||||
|
||||
/* The image is now removed from disk. Now also remove our stored record */
|
||||
r = home_unlink_record(h);
|
||||
@@ -2063,12 +2062,17 @@ int home_unregister(Home *h, sd_bus_error *error) {
|
||||
return sd_bus_error_setf(error, BUS_ERROR_HOME_BUSY, "Home %s is currently being used, or an operation on home %s is currently being executed.", h->user_name, h->user_name);
|
||||
}
|
||||
|
||||
Manager *m = ASSERT_PTR(h->manager);
|
||||
|
||||
r = home_unlink_record(h);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* And destroy the whole entry. The caller needs to be prepared for that. */
|
||||
h = home_free(h);
|
||||
|
||||
/* Let's rescan, who knows, maybe this revealed a directory in /home/ that we should pick up now */
|
||||
manager_enqueue_rescan(m);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user