From a092ce3940929f594d1f55d945cf43081706fb4b Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Wed, 24 Dec 2014 15:10:43 +0000 Subject: [PATCH] aft: Generate a remove event when adding duplicate files. Consider the following scenario: add /foo.mp3 add /bar.mp3 # assume foo and bar differ cp /foo.mp3 /bar.mp3 add /bar.mp3 In the last add command, the path being added (/bar.mp3) already exists in the audio file table, and its hash also exists for a different path (/foo.mp3). The code in aft.c is smart enough to detect this. It first removes the existing entry for /bar.mp3 and then considers the addition of /bar.mp3 as a file rename /foo.mp3 -> /bar.mp3. Unfortunately, we miss to generate the remove event in this case. This patch should fix it. It also improves the message a bit. --- aft.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aft.c b/aft.c index 61fd9942..301da7c7 100644 --- a/aft.c +++ b/aft.c @@ -1718,10 +1718,11 @@ static void com_add_callback(int fd, const struct osl_object *query) struct osl_object obj; if (pb) { /* hs trumps pb, remove pb */ if (flags & ADD_FLAG_VERBOSE) { - ret = para_printf(&msg, "removing path brother\n"); + ret = para_printf(&msg, "removing %s\n", path); if (ret < 0) goto out; } + afs_event(AUDIO_FILE_REMOVE, &msg, pb); ret = osl(osl_del_row(audio_file_table, pb)); if (ret < 0) goto out; -- 2.39.5