diff options
-rw-r--r-- | share/www/script/couch_tests.js | 9 | ||||
-rw-r--r-- | src/couchdb/couch_db.erl | 13 |
2 files changed, 11 insertions, 11 deletions
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index c65e98b5..852f9cfe 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -1331,14 +1331,13 @@ var tests = { T(xhr.status == 202); // compaction isn't instantaneous, loop until done while (db.info().compact_running) {}; - + + restartServer(); var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt"); T(xhr.responseText == "This is a base64 encoded text") T(xhr.getResponseHeader("Content-Type") == "text/plain") - - var compactedsize = db.info().disk_size; - - T(compactedsize < deletesize); + T(db.info().doc_count == 1); + T(db.info().disk_size < deletesize); } }; diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl index 8d671ea2..2f5df3b5 100644 --- a/src/couchdb/couch_db.erl +++ b/src/couchdb/couch_db.erl @@ -568,16 +568,17 @@ update_loop(#db{fd=Fd,name=Name, init_db(Name, CompactFilepath, NewFd, NewHeader), case Db#db.update_seq == NewSeq of true -> + NewDb2 = commit_data( + NewDb#db{ + main_pid = Db#db.main_pid, + doc_count = Db#db.doc_count, + doc_del_count = Db#db.doc_del_count, + filepath = Filepath}), + ?LOG_DEBUG("CouchDB swapping files ~s and ~s.", [Filepath, CompactFilepath]), ok = file:rename(Filepath, Filepath ++ ".old"), ok = file:rename(CompactFilepath, Filepath), - NewDb2 = NewDb#db{ - main_pid = Db#db.main_pid, - doc_count = Db#db.doc_count, - doc_del_count = Db#db.doc_del_count, - filepath = Filepath}, - couch_stream:close(Db#db.summary_stream), % close file handle async. % wait 5 secs before closing, allowing readers to finish |