]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
aft: Generate a remove event when adding duplicate files.
authorAndre Noll <maan@tuebingen.mpg.de>
Wed, 24 Dec 2014 15:10:43 +0000 (15:10 +0000)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 11 Jan 2015 14:56:27 +0000 (15:56 +0100)
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

diff --git a/aft.c b/aft.c
index 61fd9942242760ca7d244cf688787870bf4b0268..301da7c7687ab1a461ec6e157ba44717f21135f0 100644 (file)
--- 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;