From 343c64f2e715864266edf041d31e59cbb0035532 Mon Sep 17 00:00:00 2001 Message-Id: <343c64f2e715864266edf041d31e59cbb0035532.1718511470.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sat, 26 Apr 2008 14:51:46 +0100 Subject: [PATCH] Log the time at which newly noticed tracks are added to the database. This will allow disorder-choose to add a bias in favor of those tracks (cf defect 11). Organization: Straylight/Edgeware From: Richard Kettlewell --- lib/trackdb.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/trackdb.c b/lib/trackdb.c index 53d7cf3..54016ba 100644 --- a/lib/trackdb.c +++ b/lib/trackdb.c @@ -1014,7 +1014,8 @@ int trackdb_notice_tid(const char *track, int err, n; struct kvp *t, *a, *p; int t_changed, ret; - char *alias, **w; + char *alias, **w, *noticed; + time_t now; /* notice whether the tracks.db entry changes */ t_changed = 0; @@ -1025,6 +1026,12 @@ int trackdb_notice_tid(const char *track, /* this is a real track */ t_changed += kvp_set(&t, "_alias_for", 0); t_changed += kvp_set(&t, "_path", path); + time(&now); + if(ret == DB_NOTFOUND) { + /* It's a new track; record the time */ + byte_xasprintf(¬iced, "%lld", (long long)now); + t_changed += kvp_set(&t, "_noticed", noticed); + } /* if we have an alias record it in the database */ if((err = compute_alias(&alias, track, p, tid))) return err; if(alias) { @@ -1049,10 +1056,8 @@ int trackdb_notice_tid(const char *track, return err; if(ret == DB_NOTFOUND) { uint32_t timestamp[2]; - time_t now; DBT key, data; - time(&now); timestamp[0] = htonl((uint64_t)now >> 32); timestamp[1] = htonl((uint32_t)now); memset(&key, 0, sizeof key); -- [mdw]