Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id EDDBE429E28 for ; Tue, 13 Dec 2011 09:12:09 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.1 X-Spam-Level: X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id puNn2LE3EOTM for ; Tue, 13 Dec 2011 09:12:09 -0800 (PST) Received: from ks3536.kimsufi.com (schnouki.net [87.98.217.222]) by olra.theworths.org (Postfix) with ESMTP id E8EC8429E25 for ; Tue, 13 Dec 2011 09:12:08 -0800 (PST) Received: from thor.loria.fr (thor.loria.fr [152.81.12.250]) by ks3536.kimsufi.com (Postfix) with ESMTPSA id C491D6A0026; Tue, 13 Dec 2011 18:12:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=schnouki.net; s=key-schnouki; t=1323796327; bh=8CV2PirzdQgi3G82froq5+HvXxRthKJ/3+tfZJVPYYA=; h=From:To:Subject:Date:Message-Id; b=m0JZCcwGOrrlfZqgtNQridMZzmBQWR3d0flp/pQTyFgU69mSREKPk0u20hWPPnGWz j1PRyTrbzl8bMOr5mGPiXTSzy45PT5WrJbCseMOR2LLxiV2+R+9CifmInlJBro7qJF hTeayDeUV7yc+jxLlBJFOe+Q9yax5GeI2D2vVAsA= From: Thomas Jost To: notmuch@notmuchmail.org Subject: [PATCH 0/5] Store message modification times in the DB Date: Tue, 13 Dec 2011 18:11:40 +0100 Message-Id: <1323796305-28789-1-git-send-email-schnouki@schnouki.net> X-Mailer: git-send-email 1.7.8 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Dec 2011 17:12:10 -0000 Hello world, This is a patch series I've been working on for some time in order to be able to sync my tags on several computers. I'm posting it now, but please consider it as a RFC rather than something that is ready to be pushed. The basic idea is to the last time each message was modified, i.e. "the message was added to the DB", "a tag was added" or "a tag was removed". This mtime is accessible through a library function and in the JSON output of "notmuch show". It is also searchable with the "mtime:" prefix and with timestamp ranges, like for searching messages by date: notmuch search mtime:$(date +%s 2011-12-01)..$(date +%s) This can then be used in scripts or helper programs to do incremental dumps or tags synchronization. (I already have a script to do incremental backups, but it needs some cleaning, and I'm still working on something for sync'ing tags, but it's starting to work really well; I'll post them later). This can be seen as an alternative to David Bremner's jlog branch, but with several differences: + no external dependency + everything is stored in the notmuch DB: atomicity for free! - when a message is removed we lose everything about it, which makes the sync process more complicated - for a human, it's harder to manipulate timestamps than log messages - this can store much less data than a proper log system On IRC amdragon suggested using a simple sequence number instead of a timestamp. This would indeed eliminate the need for proper time synchronization between computers one would want to keep in sync, and it would reduce the risk of time-going-backward problems, but IMHO it would cause more problems: no global clock --> no simple way to tell if DB #A is more recent than DB #B. So, here are the patches: - first a little fix to the comments describing the DB schema (not specific to this patch series at all, I just noticed it when rebasing this series) - the second commit adds the MTIME value to the database schema, and creates the functions used to update and access this value. - the third commit makes the MTIME value searchable with a range syntax. - the fourth commit adds the MTIME to the JSON output of "notmuch show". - the fifth and last commit adds Message.get_mtime() to the Python bindings. Please tell me what you think of this. Best regards, Thomas Thomas Jost (5): Fix comments about what is stored in the database lib: Add a MTIME value to every mail document lib: Make MTIME values searchable show: include mtime in JSON output python: add get_mtime() to the Message class bindings/python/notmuch/message.py | 20 ++++++++++++++++++++ lib/database-private.h | 1 + lib/database.cc | 14 +++++++++++++- lib/message.cc | 32 ++++++++++++++++++++++++++++++++ lib/notmuch-private.h | 6 +++++- lib/notmuch.h | 4 ++++ notmuch-show.c | 7 ++++--- notmuch.1 | 14 ++++++++++++-- notmuch.c | 13 ++++++++++--- 9 files changed, 101 insertions(+), 10 deletions(-) -- 1.7.8