couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r960150 - in /couchdb/trunk: THANKS src/couchdb/couch_file.erl src/couchdb/couch_server.erl
Date Sat, 03 Jul 2010 03:34:11 GMT
Author: damien
Date: Sat Jul  3 03:34:10 2010
New Revision: 960150

URL: http://svn.apache.org/viewvc?rev=960150&view=rev
Log:
Fixed intermittent problem deleting files on Windows. Added Juhani Ränkimies to THANKS

Modified:
    couchdb/trunk/THANKS
    couchdb/trunk/src/couchdb/couch_file.erl
    couchdb/trunk/src/couchdb/couch_server.erl

Modified: couchdb/trunk/THANKS
URL: http://svn.apache.org/viewvc/couchdb/trunk/THANKS?rev=960150&r1=960149&r2=960150&view=diff
==============================================================================
--- couchdb/trunk/THANKS (original)
+++ couchdb/trunk/THANKS Sat Jul  3 03:34:10 2010
@@ -62,5 +62,6 @@ suggesting improvements or submitting ch
  * Brian Jenkins <bonkydog@bonkydog.com>
  * Paul Bonser <pib@paulbonser.com>
  * Caleb Land <caleb.land@gmail.com>
+ * Juhani Ränkimies <juhani@juranki.com>
 
 For a list of authors see the `AUTHORS` file.

Modified: couchdb/trunk/src/couchdb/couch_file.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_file.erl?rev=960150&r1=960149&r2=960150&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_file.erl (original)
+++ couchdb/trunk/src/couchdb/couch_file.erl Sat Jul  3 03:34:10 2010
@@ -28,7 +28,7 @@
 -export([pread_binary/2, read_header/1, truncate/2, upgrade_old_header/2]).
 -export([append_term_md5/2,append_binary_md5/2]).
 -export([init/1, terminate/2, handle_call/3, handle_cast/2, code_change/3, handle_info/2]).
--export([delete/1]).
+-export([delete/1,init_delete_dir/0]).
 
 %%----------------------------------------------------------------------
 %% Args:   Valid Options are [create] and [create,overwrite].
@@ -171,14 +171,28 @@ close(Fd) ->
     end.
 
 delete(Filepath) ->
-    case file:rename(Filepath, Filepath ++ ".delete") of
+    DbDir = couch_config:get("couchdb", "database_dir"),
+    DelFile = filename:join([DbDir,".delete", ?b2l(couch_uuids:random())]),
+    case file:rename(Filepath, DelFile) of
     ok ->
-        spawn(file, delete, [Filepath ++ ".delete"]),
+        spawn(file, delete, [DelFile]),
         ok;
     Error ->
         Error
     end.
 
+
+init_delete_dir() ->
+    Dir = filename:join(couch_config:get("couchdb","database_dir"),".delete"),
+    % note: ensure_dir requires an actual filename companent, which is the
+    % reason for "foo".
+    filelib:ensure_dir(filename:join(Dir,"foo")),
+    filelib:fold_files(Dir, ".*", true,
+        fun(Filename, _) ->
+            ok = file:delete(Filename)
+        end, ok).
+
+
 % 09 UPGRADE CODE
 old_pread(Fd, Pos, Len) ->
     {ok, <<RawBin:Len/binary>>, false} = gen_server:call(Fd, {pread, Pos, Len},
infinity),

Modified: couchdb/trunk/src/couchdb/couch_server.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_server.erl?rev=960150&r1=960149&r2=960150&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_server.erl (original)
+++ couchdb/trunk/src/couchdb/couch_server.erl Sat Jul  3 03:34:10 2010
@@ -131,6 +131,7 @@ init([]) ->
             gen_server:call(couch_server,
                     {set_max_dbs_open, list_to_integer(Max)})
         end),
+    ok = couch_file:init_delete_dir(),
     hash_admin_passwords(),
     ok = couch_config:register(
         fun("admins", _Key, _Value, Persist) ->



Mime
View raw message