From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Wiegley Newsgroups: gmane.emacs.devel Subject: [PATCH 2/2] nnmaildir: Use a 'num' file, instead of a directory Date: Thu, 27 May 2010 15:09:08 -0600 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1078) Content-Type: multipart/mixed; boundary=Apple-Mail-3-334605379 X-Trace: dough.gmane.org 1274998471 29472 80.91.229.12 (27 May 2010 22:14:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 27 May 2010 22:14:31 +0000 (UTC) To: "emacs-devel@gnu.org devel" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 28 00:14:24 2010 connect(): No such file or directory Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OHlLK-0002m6-EG for ged-emacs-devel@m.gmane.org; Fri, 28 May 2010 00:14:23 +0200 Original-Received: from localhost ([127.0.0.1]:36293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHlLJ-0007nP-9U for ged-emacs-devel@m.gmane.org; Thu, 27 May 2010 18:14:21 -0400 Original-Received: from [140.186.70.92] (port=49569 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHkPK-00078I-Ay for emacs-devel@gnu.org; Thu, 27 May 2010 17:14:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OHkKI-0008Sg-Cz for emacs-devel@gnu.org; Thu, 27 May 2010 17:09:18 -0400 Original-Received: from mail-pz0-f192.google.com ([209.85.222.192]:51371) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OHkKI-0008SP-40 for emacs-devel@gnu.org; Thu, 27 May 2010 17:09:14 -0400 Original-Received: by pzk30 with SMTP id 30so456682pzk.6 for ; Thu, 27 May 2010 14:09:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:content-type:subject :date:message-id:to:mime-version:x-mailer; bh=94xsfEIgfJPl+CvVUD/ORna/Wj/e611cC9BAPPba92E=; b=PgPc+0RL7jwcSYC4FAZR0e36WqtZlDTZCfy/SMxZb9ZYaaayuBRGWvJ7DqDYwKmzNN VJougSF5aYJGB9otLTMjAsqurBlFByna1cTaEn3OxDEF133c+IjUHbrYLmsDKPDMjVYr SPDpdeJBIXboEqtwzB7/4+7+gUjSmWC4xzmdI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:content-type:subject:date:message-id:to:mime-version:x-mailer; b=rl9U29Azd11YuWzNOaJyj987Vz1ZBNpmLziKGAHJeFD4LSz4D3yo2ptILYfGu+l3/K LQeqtnj0hP8Y2FaXyb5ln68oVVZv/NvIVTaImc/zhpDPp45ueI+1kHuQm6LFho4eCqtx yCv3wEAzOb4RSn6TOExZCEiPzK4V1DIIWiuEE= Original-Received: by 10.141.2.9 with SMTP id e9mr240879rvi.51.1274994552814; Thu, 27 May 2010 14:09:12 -0700 (PDT) Original-Received: from [192.168.0.3] (174-24-43-180.clsp.qwest.net [174.24.43.180]) by mx.google.com with ESMTPS id b12sm1406789rvn.10.2010.05.27.14.09.10 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 27 May 2010 14:09:11 -0700 (PDT) X-Mailer: Apple Mail (2.1078) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:125311 Archived-At: --Apple-Mail-3-334605379 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii This patch causes nnmaildir to use a "num" file to track the next = available article number, rather than creating N empty files. However, = this only works for new groups. Existing groups, which use the = directory, will continue to. If you want to switch to using file-based = numbering, you must convert your Maildir using the attached script (it's = also copied to the commit description in the patch). John --Apple-Mail-3-334605379 Content-Disposition: attachment; filename=0002-nnmaildir-Use-a-num-file-instead-of-a-directory.patch Content-Type: application/octet-stream; name="0002-nnmaildir-Use-a-num-file-instead-of-a-directory.patch" Content-Transfer-Encoding: quoted-printable =46rom=20d80163c6686b7b8a9a24ff94d61baddbcdd0364c=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20John=20Wiegley=20=0A= Date:=20Thu,=2027=20May=202010=2015:03:10=20-0600=0ASubject:=20[PATCH=20= 2/2]=20nnmaildir:=20Use=20a=20'num'=20file,=20instead=20of=20a=20= directory=0A=0A---=0A=20nnmaildir.el=20|=20=20=2040=20= +++++++++++++++++++++++++++++++++++++---=0A=201=20files=20changed,=2037=20= insertions(+),=203=20deletions(-)=0A=0Adiff=20--git=20a/nnmaildir.el=20= b/nnmaildir.el=0Aindex=20fde1fc8..1991321=20100644=0A---=20= a/nnmaildir.el=0A+++=20b/nnmaildir.el=0A@@=20-236,6=20+236,9=20@@=20by=20= nnmaildir-request-article.")=0A=20(defmacro=20nnmaildir--marks-dir=20= (dir)=20`(nnmaildir--subdir=20,dir=20"marks"))=0A=20(defmacro=20= nnmaildir--num-dir=20=20=20(dir)=20`(nnmaildir--subdir=20,dir=20"num"))=0A= =20=0A+(defun=20nnmaildir--num-file=20=20(dir)=0A+=20=20= (expand-file-name=20"num"=20dir))=0A+=0A=20(defmacro=20nnmaildir--unlink=20= (file-arg)=0A=20=20=20`(let=20((file=20,file-arg))=0A=20=20=20=20=20=20= (if=20(file-attributes=20file)=20(delete-file=20file))))=0A@@=20-249,7=20= +252,7=20@@=20by=20nnmaildir-request-article.")=0A=20=20=20=20=20(mapc=20= 'delete-file=20(funcall=20ls=20dir=20'full=20"\\`[^.]"=20'nosort))=0A=20=20= =20=20=20(delete-directory=20dir)))=0A=20=0A-(defun=20= nnmaildir--group-maxnum=20(server=20group)=0A+(defun=20= nnmaildir--group-maxnum-from-dir=20(server=20group)=0A=20=20=20(catch=20= 'return=0A=20=20=20=20=20(if=20(zerop=20(nnmaildir--grp-count=20group))=20= (throw=20'return=200))=0A=20=20=20=20=20(let=20((dir=20= (nnmaildir--srvgrp-dir=20(nnmaildir--srv-dir=20server)=0A@@=20-273,6=20= +276,21=20@@=20by=20nnmaildir-request-article.")=0A=20=09(unless=20= (equal=20ino-opened=20(nth=2010=20attr))=0A=20=09=20=20(setq=20= number-opened=20number-linked))))))=0A=20=0A+(defun=20= nnmaildir--group-maxnum=20(server=20group)=0A+=20=20(if=20(zerop=20= (nnmaildir--grp-count=20group))=0A+=20=20=20=20=20=200=0A+=20=20=20=20= (let=20((file=20(nnmaildir--num-file=0A+=09=09=20(nnmaildir--nndir=0A+=09= =09=20=20(nnmaildir--srvgrp-dir=20(nnmaildir--srv-dir=20server)=0A+=09=09= =09=09=09=20(nnmaildir--grp-name=20group))))))=0A+=20=20=20=20=20=20(if=20= (file-directory-p=20file)=0A+=09=20=20(nnmaildir--group-maxnum-from-dir=20= server=20group)=0A+=09(if=20(file-exists-p=20file)=0A+=09=20=20=20=20= (with-temp-buffer=0A+=09=20=20=20=20=20=20(insert-file-contents=20file)=0A= +=09=20=20=20=20=20=20(read=20(current-buffer)))=0A+=09=20=200)))))=0A+=0A= =20;;=20Make=20the=20given=20server,=20if=20non-nil,=20be=20the=20= current=20server.=20=20Then=20make=20the=0A=20;;=20given=20group,=20if=20= non-nil,=20be=20the=20current=20group=20of=20the=20current=20server.=20=20= Then=0A=20;;=20return=20the=20group=20object=20for=20the=20current=20= group.=0A@@=20-324,8=20+342,7=20@@=20by=20nnmaildir-request-article.")=0A= =20(defun=20nnmaildir--eexist-p=20(err)=0A=20=20=20(eq=20(car=20err)=20= 'file-already-exists))=0A=20=0A-(defun=20nnmaildir--new-number=20(nndir)=0A= -=20=20"Allocate=20a=20new=20article=20number=20by=20atomically=20= creating=20a=20file=20under=20NNDIR."=0A+(defun=20= nnmaildir--new-number-from-dir=20(nndir)=0A=20=20=20(let=20((numdir=20= (nnmaildir--num-dir=20nndir))=0A=20=09(make-new-file=20t)=0A=20=09= (number-open=201)=0A@@=20-366,6=20+383,23=20@@=20by=20= nnmaildir-request-article.")=0A=20=09=09=20=20=20=20=20=20number-link=20= 0))))=0A=20=09=20=20=20(t=20(signal=20(car=20err)=20(cdr=20err)))))))))=0A= =20=0A+(defun=20nnmaildir--new-number=20(nndir)=0A+=20=20"Allocate=20a=20= new=20article=20number=20by=20atomically=20creating=20a=20file=20under=20= NNDIR."=0A+=20=20(let=20((numfile=20(nnmaildir--num-file=20nndir))=0A+=09= (number=200))=0A+=20=20=20=20(if=20(file-directory-p=20numfile)=0A+=09= (nnmaildir--new-number-from-dir=20nndir)=0A+=20=20=20=20=20=20= (with-current-buffer=20(find-file-noselect=20numfile=20t=20t)=0A+=09= (goto-char=20(point-min))=0A+=09(unless=20(eobp)=0A+=09=20=20(setq=20= number=20(1+=20(read=20(current-buffer))))=0A+=09=20=20(delete-region=20= (point-min)=20(point-max)))=0A+=09(insert=20(number-to-string=20number))=0A= +=09(write-region=20(point-min)=20(point-max)=20numfile=20nil=20= 'no-message)=0A+=09(set-buffer-modified-p=20nil)=0A+=09(kill-buffer=20= (current-buffer)))=0A+=20=20=20=20=20=20number)))=0A+=0A=20(defun=20= nnmaildir--update-nov=20(server=20group=20article)=0A=20=20=20(let=20= ((nnheader-file-coding-system=20'binary)=0A=20=09(srv-dir=20= (nnmaildir--srv-dir=20server))=0A--=20=0A1.7.1=0A=0A= --Apple-Mail-3-334605379 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail-3-334605379 Content-Disposition: attachment; filename=gnus-renumber Content-Type: application/octet-stream; x-unix-mode=0755; name="gnus-renumber" Content-Transfer-Encoding: 7bit #!/bin/sh dryrun=false if [ "$1" = "-n" ]; then dryrun=true shift 1 fi find $1 -name .nnmaildir -type d | \ while read nndir; do if [ -d "$nndir"/num ]; then last=$(find "$nndir"/num -type f | sed -e 's/.*\///' | sort -n | tail -1) if [ $dryrun = true ]; then echo rm -fr "$nndir"/num echo echo $last '>' "$nndir"/num else rm -fr "$nndir"/num echo $last > "$nndir"/num fi fi done --Apple-Mail-3-334605379--