From 03a01f3a778b475fee6b90818ec4bf8d4214afd5 Mon Sep 17 00:00:00 2001 Message-Id: <03a01f3a778b475fee6b90818ec4bf8d4214afd5.1715017812.git.mdw@distorted.org.uk> From: Mark Wooding Date: Thu, 12 Jun 2008 20:29:33 +0100 Subject: [PATCH] When listing a directory which contains an alias for a track in that directory, it is now the alias that is skipped rather than the real name. None of the possibilities here are very attractive but this one seems to be easier to write UIs against. Organization: Straylight/Edgeware From: Richard Kettlewell --- lib/trackdb.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/trackdb.c b/lib/trackdb.c index 4009358..56a8e8d 100644 --- a/lib/trackdb.c +++ b/lib/trackdb.c @@ -1852,7 +1852,7 @@ static int do_list(struct vector *v, const char *dir, char *ptr; int err; size_t l, last_dir_len = 0; - char *last_dir = 0, *track, *alias; + char *last_dir = 0, *track; struct kvp *p; dl = strlen(dir); @@ -1885,12 +1885,35 @@ static int do_list(struct vector *v, const char *dir, if((err = trackdb_getdata(trackdb_prefsdb, track, &p, tid)) == DB_LOCK_DEADLOCK) goto deadlocked; + /* There's an awkward question here... + * + * If a track shares a directory with its alias then we could + * do one of three things: + * - report both. Looks ridiculuous in most UIs. + * - report just the alias. Remarkably inconvenient to write + * UI code for! + * - report just the real name. Ugly if the UI doesn't prettify + * names via the name parts. + */ +#if 1 + /* If this file is an alias for a track in the same directory then we + * skip it */ + struct kvp *t = kvp_urldecode(d.data, d.size); + const char *alias_target = kvp_get(t, "_alias_for"); + if(!(alias_target + && !strcmp(d_dirname(alias_target), + d_dirname(track)))) + if(track_matches(dl, k.data, k.size, re)) + vector_append(v, track); +#else /* if this file has an alias in the same directory then we skip it */ + char *alias; if((err = compute_alias(&alias, track, p, tid))) goto deadlocked; if(!(alias && !strcmp(d_dirname(alias), d_dirname(track)))) if(track_matches(dl, k.data, k.size, re)) vector_append(v, track); +#endif } } err = cursor->c_get(cursor, &k, &d, DB_NEXT); -- [mdw]