From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id E5EF86DE0115 for ; Thu, 18 May 2017 15:25:49 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.062 X-Spam-Level: X-Spam-Status: No, score=-0.062 tagged_above=-999 required=5 tests=[AWL=-0.041, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NFdyQSVNCwJl for ; Thu, 18 May 2017 15:25:49 -0700 (PDT) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by arlo.cworth.org (Postfix) with ESMTPS id 94FFA6DE0355 for ; Thu, 18 May 2017 15:25:45 -0700 (PDT) Received: by mail-wm0-f67.google.com with SMTP id y10so14372965wmh.0 for ; Thu, 18 May 2017 15:25:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adirat-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=3Ryd+YrN0la6z3I/2zVay2J2f2pFIusdg7dC6l4yYk4=; b=SoOPJ4TCrd5/S4Jw8oBic0MtbFnxZaHM7C7e9TBv9Wl7dqrlBUv6F/aNw85vlRb0mS U6MRTijN8kLvto3FaxdiR3lMNXbfbSUhwZ8LxRCvBEfY47lAtS0b+NQLe0OlsBQNxuy1 1ntAgi/4xrITCbm2Cm5J/dZDoOfnrRWmKg91WoRAPhNo4+kLabeGR1xQ+Z+0ML1CLMug n+cWxWq4+QA7JdmTIGFCrSf0LceLEveN+2+KT8AWvtvrWgdRIWf6KpClaMJVhSZ9XnP8 lwcYoYjDmTvu+WTx+joSq1kh7g18fgTpc7rVuVKJp/N0Ib1IZIPQbmt4Nh06O14F0J/l s+XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=3Ryd+YrN0la6z3I/2zVay2J2f2pFIusdg7dC6l4yYk4=; b=IGQN6JSTLvgwKqHjTuPqRO9R1rfFuC/+HZW1IsNPAr4jPYuGOooSXrD5yxZl4benYe PU/jNiaZ8anGmimQu5RILMiF9diU667dXAWw9/DyslvDJKsgZnzyOnvFbcVNDpTTaAMH uoy/zYX+jsrVjmL7lP5hbD4p8LvvxVaK+DQfEJZlPhqeR37QhE+3MtFC5xXp1zktaFba 1hRwmbuwCiYU0XQG+H6xSI21kslcO9ai4CC8Uoo6Ny1aj45Qc2L5jPQ2IEZ65UDJnniF GYYbmbo0w/GImphVQKlQCB/ksj1JG7Q52v6o69n6iVWjolupqHVE7xe5sgu8ZBTmcfPc RTag== X-Gm-Message-State: AODbwcDyqYMTjnytPIzDVMJT62Mdtjnntr8/OPl/Wa5833IjYSN0lJVc Wq6Sn1lW9LCs70lsyag= X-Received: by 10.28.1.198 with SMTP id 189mr4180456wmb.18.1495146344114; Thu, 18 May 2017 15:25:44 -0700 (PDT) Received: from adiPC.adirat.com ([82.137.23.239]) by smtp.gmail.com with ESMTPSA id q16sm8141390wmg.2.2017.05.18.15.25.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 May 2017 15:25:43 -0700 (PDT) From: Ioan-Adrian Ratiu To: notmuch@notmuchmail.org Subject: [PATCH v2 07/11] lib: thread: add thread total size function Date: Fri, 19 May 2017 01:27:04 +0300 Message-Id: <20170518222708.30032-8-adi@adirat.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170518222708.30032-1-adi@adirat.com> References: <20170518222708.30032-1-adi@adirat.com> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 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: Thu, 18 May 2017 22:25:50 -0000 Given a thread object this function computes the total disk space used by all messages contained in the thread. Signed-off-by: Ioan-Adrian Ratiu --- lib/notmuch.h | 7 +++++++ lib/thread.cc | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/notmuch.h b/lib/notmuch.h index b7bf3526..4f2afbe4 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -1185,6 +1185,13 @@ time_t notmuch_thread_get_newest_date (notmuch_thread_t *thread); /** + * Get the total disk space used by the thread i.e. a sum of the + * thread messages filesizes. + */ +unsigned long +notmuch_thread_get_total_filesize (notmuch_thread_t *thread); + +/** * Get the tags for 'thread', returning a notmuch_tags_t object which * can be used to iterate over all tags. * diff --git a/lib/thread.cc b/lib/thread.cc index 1a1ecfa5..72878b62 100644 --- a/lib/thread.cc +++ b/lib/thread.cc @@ -596,6 +596,18 @@ notmuch_thread_get_newest_date (notmuch_thread_t *thread) return thread->newest; } +unsigned long +notmuch_thread_get_total_filesize (notmuch_thread_t *thread) +{ + notmuch_message_node_t *node; + unsigned long total_filesize = 0; + + for (node = thread->message_list->head; node; node = node->next) + total_filesize += notmuch_message_get_filesize (node->message); + + return total_filesize; +} + notmuch_tags_t * notmuch_thread_get_tags (notmuch_thread_t *thread) { -- 2.13.0