Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A823CDC1C for ; Thu, 20 Dec 2012 17:57:32 +0000 (UTC) Received: (qmail 57231 invoked by uid 500); 20 Dec 2012 17:57:32 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 57116 invoked by uid 500); 20 Dec 2012 17:57:32 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 56977 invoked by uid 99); 20 Dec 2012 17:57:32 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Dec 2012 17:57:32 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 3D021324CB5; Thu, 20 Dec 2012 17:57:32 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rnewson@apache.org To: commits@couchdb.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [2/2] git commit: Delete view files on database deletion Message-Id: <20121220175732.3D021324CB5@tyr.zones.apache.org> Date: Thu, 20 Dec 2012 17:57:32 +0000 (UTC) Delete view files on database deletion couch_file:nuke_dir attempts to recurse into subdirectories and delete the contents, it does so when couch_file:delete returns {error, eperm}. Unfortunately, the subdirectory has been renamed to a random uuid before returning, and so the recursive call gets {error, enoent} from list:dir(Path) where Path is the original (non-existent) subdirectory path. View files are not currently deleted when a database is because of this (this happened since 1.2.0, no release is broken) because the view engine rewrite added a further directory level called 'mrview'. This patch modifies nuke_dir to depth-first, solving the issue. Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/5b9708b6 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/5b9708b6 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/5b9708b6 Branch: refs/heads/master Commit: 5b9708b68ce6d68f4f40235ea880f299b5dcd9e3 Parents: fb3a1ea Author: Robert Newson Authored: Thu Dec 20 17:05:37 2012 +0000 Committer: Robert Newson Committed: Thu Dec 20 17:32:48 2012 +0000 ---------------------------------------------------------------------- src/couchdb/couch_file.erl | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b9708b6/src/couchdb/couch_file.erl ---------------------------------------------------------------------- diff --git a/src/couchdb/couch_file.erl b/src/couchdb/couch_file.erl index 54ff693..ee5dafb 100644 --- a/src/couchdb/couch_file.erl +++ b/src/couchdb/couch_file.erl @@ -223,10 +223,12 @@ delete(RootDir, Filepath, Async) -> nuke_dir(RootDelDir, Dir) -> FoldFun = fun(File) -> Path = Dir ++ "/" ++ File, - case delete(RootDelDir, Path, false) of - {error, eperm} -> ok = nuke_dir(RootDelDir, Path); - {error, enoent} -> ok; - ok -> ok + case filelib:is_dir(Path) of + true -> + ok = nuke_dir(RootDelDir, Path), + file:del_dir(Path); + false -> + delete(RootDelDir, Path, false) end end, case file:list_dir(Dir) of