You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2012/08/15 23:32:37 UTC

git commit: Support all timezones for R14 series

Updated Branches:
  refs/heads/master b59ac98b4 -> 445e9190f


Support all timezones for R14 series


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

Branch: refs/heads/master
Commit: 445e9190fc25e64d7f9d121cb2d2945743a02843
Parents: b59ac98
Author: Robert Newson <rn...@apache.org>
Authored: Wed Aug 15 22:32:15 2012 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Wed Aug 15 22:32:29 2012 +0100

----------------------------------------------------------------------
 src/mochiweb/mochiweb_request.erl |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/445e9190/src/mochiweb/mochiweb_request.erl
----------------------------------------------------------------------
diff --git a/src/mochiweb/mochiweb_request.erl b/src/mochiweb/mochiweb_request.erl
index 2bc54c0..dfd439d 100644
--- a/src/mochiweb/mochiweb_request.erl
+++ b/src/mochiweb/mochiweb_request.erl
@@ -600,7 +600,7 @@ maybe_redirect(RelPath, FullPath, ExtraHeaders) ->
     end.
 
 maybe_serve_file(File, ExtraHeaders) ->
-    case file:read_file_info(File, [{time, universal}]) of
+    case read_file_info(File) of
         {ok, FileInfo} ->
             LastModified = couch_util:rfc1123_date(FileInfo#file_info.mtime),
             case get_header_value("if-modified-since") of
@@ -624,6 +624,25 @@ maybe_serve_file(File, ExtraHeaders) ->
             not_found(ExtraHeaders)
     end.
 
+read_file_info(File) ->
+    try
+        file:read_file_info(File, [{time, universal}])
+    catch error:undef ->
+        case file:read_file_info(File) of
+            {ok, FileInfo} ->
+                {ok, FileInfo#file_info{
+                       atime=to_universal(FileInfo#file_info.atime),
+                       mtime=to_universal(FileInfo#file_info.mtime),
+                       ctime=to_universal(FileInfo#file_info.ctime)
+                      }};
+            Else ->
+                Else
+        end
+    end.
+
+to_universal(LocalTime) ->
+    calendar:local_time_to_universal_time(LocalTime).
+
 server_headers() ->
     [{"Server", "MochiWeb/1.0 (" ++ ?QUIP ++ ")"},
      {"Date", couch_util:rfc1123_date()}].