Diff
Not logged in

Differences From:

File src/tag.c part of check-in [e4517465f3] - Autosync is now working. Added autosync to tag add, tag branch and branch create. by jnc on 2007-09-25 07:19:55. [view]

To:

File src/tag.c part of check-in [ce7900a0b6] - Correct tag propagationl. Now works even when rebuilding in a randomized order. by drh on 2007-09-25 08:38:24. [view]

@@ -152,10 +152,26 @@
 ){
   Stmt s;
   const char *zCol;
   int tagid = tag_findid(zTag, 1);
+  int rc;
+
   if( mtime<=0.0 ){
     mtime = db_double(0.0, "SELECT julianday('now')");
+  }
+  db_prepare(&s,
+    "SELECT 1 FROM tagxref"
+    " WHERE tagid=%d"
+    "   AND rid=%d"
+    "   AND mtime>=:mtime",
+    tagid, rid
+  );
+  db_bind_double(&s, ":mtime", mtime);
+  rc = db_step(&s);
+  db_finalize(&s);
+  if( rc==SQLITE_ROW ){
+    /* Another entry this is more recent already exists.  Do nothing */
+    return;
   }
   db_prepare(&s,
     "REPLACE INTO tagxref(tagid,tagtype,srcId,value,mtime,rid)"
     " VALUES(%d,%d,%d,%Q,:mtime,%d)",