Webdav upload and wrong modify time stamp (0.7.65, 0.8.34)

Maxim Dounin mdounin at mdounin.ru
Tue Mar 30 15:34:08 MSD 2010


Hello!

On Tue, Mar 30, 2010 at 01:16:00PM +0200, Marcin Engelmann wrote:

> I noticed that uploading file (webdav) when client_body_temp_path and
> document root are on different partitions sets access and modify time
> stamps to 1970-01-01 instead of valid time. It works fine if
> client_body_temp_path and document root are on the same partition.

Try the attached patch.

Maxim Dounin
-------------- next part --------------
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1269948739 -14400
# Node ID a2efd44b2c85c90e88a8470f33a9da4fe21c7b85
# Parent  175b534ae706140c4b8581aac8a9c04493c6cb8d
Core: fix file time on ngx_copy_file().

Don't try to set file time if we don't have it.

diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -762,10 +762,12 @@ ngx_copy_file(u_char *from, u_char *to, 
         size -= n;
     }
 
-    if (ngx_set_file_time(to, nfd, cf->time) != NGX_OK) {
-        ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
-                      ngx_set_file_time_n " \"%s\" failed", to);
-        goto failed;
+    if (cf->time != -1) {
+        if (ngx_set_file_time(to, nfd, cf->time) != NGX_OK) {
+            ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
+                          ngx_set_file_time_n " \"%s\" failed", to);
+            goto failed;
+        }
     }
 
     rc = NGX_OK;


More information about the nginx mailing list