diff options
author | John Christopher Anderson <jchris@apache.org> | 2010-07-01 21:37:49 +0000 |
---|---|---|
committer | John Christopher Anderson <jchris@apache.org> | 2010-07-01 21:37:49 +0000 |
commit | fdcd082dfad0fd979ce46331cc98113a1683f3b4 (patch) | |
tree | cf4e9ae38a3ac2da6deaa67178d60d90feaa85ed /src | |
parent | be39860688e01e0d0749fdbefdd226d790133219 (diff) |
prevent zero byte files, closes COUCHDB-647
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@959791 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/couchdb/couch_db_updater.erl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/couchdb/couch_db_updater.erl b/src/couchdb/couch_db_updater.erl index e4eb72cc..5042e3cb 100644 --- a/src/couchdb/couch_db_updater.erl +++ b/src/couchdb/couch_db_updater.erl @@ -30,7 +30,16 @@ init({MainPid, DbName, Filepath, Fd, Options}) -> 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), |