couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r959791 - /couchdb/trunk/src/couchdb/couch_db_updater.erl
Date Thu, 01 Jul 2010 21:37:50 GMT
Author: jchris
Date: Thu Jul  1 21:37:49 2010
New Revision: 959791

URL: http://svn.apache.org/viewvc?rev=959791&view=rev
Log:
prevent zero byte files, closes COUCHDB-647

Modified:
    couchdb/trunk/src/couchdb/couch_db_updater.erl

Modified: couchdb/trunk/src/couchdb/couch_db_updater.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db_updater.erl?rev=959791&r1=959790&r2=959791&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db_updater.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db_updater.erl Thu Jul  1 21:37:49 2010
@@ -30,7 +30,16 @@ init({MainPid, DbName, Filepath, Fd, Opt
         couch_file:delete(Filepath ++ ".compact");
     false ->
         ok = couch_file:upgrade_old_header(Fd, <<$g, $m, $k, 0>>), % 09 UPGRADE
CODE
-        {ok, Header} = couch_file:read_header(Fd)
+        case couch_file:read_header(Fd) of
+        {ok, Header} ->
+            ok;
+        no_valid_header ->
+            % create a new header and writes it to the file
+            Header =  #db_header{},
+            ok = couch_file:write_header(Fd, Header),
+            % delete any old compaction files that might be hanging around
+            file:delete(Filepath ++ ".compact")
+        end
     end,
 
     Db = init_db(DbName, Filepath, Fd, Header),



Mime
View raw message