couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [7/8] git commit: Avoid reading a file if its size is 0
Date Mon, 11 Feb 2013 05:43:17 GMT
Avoid reading a file if its size is 0


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/87670bfa
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/87670bfa
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/87670bfa

Branch: refs/heads/1677-feature-query_server_log_file
Commit: 87670bfaa7fc77aeafcfbd71fd5e693c3e48ea0e
Parents: 7cd2d3d
Author: Jason Smith (work) <jhs@iriscouch.com>
Authored: Mon Feb 11 05:04:30 2013 +0000
Committer: Jason Smith (work) <jhs@iriscouch.com>
Committed: Mon Feb 11 05:29:25 2013 +0000

----------------------------------------------------------------------
 src/couchdb/couch_log.erl |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/87670bfa/src/couchdb/couch_log.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_log.erl b/src/couchdb/couch_log.erl
index 86d9bc8..937cf4b 100644
--- a/src/couchdb/couch_log.erl
+++ b/src/couchdb/couch_log.erl
@@ -283,7 +283,14 @@ get_query_server_messages(Pid, Level, Port, Message) ->
 
 read(Bytes, Offset) ->
     LogFileName = couch_config:get("log", "file"),
-    LogFileSize = filelib:file_size(LogFileName),
+    case filelib:file_size(LogFileName)
+    of 0 ->
+        "";
+    LogFileSize ->
+        read(LogFileName, LogFileSize, Bytes, Offset)
+    end.
+
+read(LogFileName, LogFileSize, Bytes, Offset) ->
     MaxChunkSize = list_to_integer(
         couch_config:get("httpd", "log_max_chunk_size", "1000000")),
     case Bytes > MaxChunkSize of


Mime
View raw message