Skip to content

Commit

Permalink
scalar unregister: stop FSMonitor daemon
Browse files Browse the repository at this point in the history
Especially on Windows, we will need to stop that daemon, just in case
that the directory needs to be removed (the daemon would otherwise hold
a handle to that directory, preventing it from being deleted).

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
dscho authored and gitster committed Aug 19, 2022
1 parent 3f1917d commit ec4c231
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions contrib/scalar/scalar.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,16 @@ static int start_fsmonitor_daemon(void)
return 0;
}

static int stop_fsmonitor_daemon(void)
{
assert(have_fsmonitor_support());

if (fsmonitor_ipc__get_state() == IPC_STATE__LISTENING)
return run_git("fsmonitor--daemon", "stop", NULL);

return 0;
}

static int register_dir(void)
{
if (add_or_remove_enlistment(1))
Expand Down Expand Up @@ -468,6 +478,9 @@ static int delete_enlistment(struct strbuf *enlistment)
strbuf_release(&parent);
#endif

if (have_fsmonitor_support() && stop_fsmonitor_daemon())
return error(_("failed to stop the FSMonitor daemon"));

if (remove_dir_recursively(enlistment, 0))
return error(_("failed to delete enlistment directory"));

Expand Down

0 comments on commit ec4c231

Please sign in to comment.