Changeset 63


Ignore:
Timestamp:
Sep 4, 2009, 7:30:35 PM (15 years ago)
Author:
Yuri Dario
Message:

Reworked timestamp handling, now conversion to GMT happens only at time of R/W to server. Fixes ticket:22.

Location:
trunk/source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/source/Makefile.kmk

    r60 r63  
    2828        ndpdav.def \
    2929        printf.c \
     30        util.cpp \
    3031        dav/dav_alloc.cpp \
    3132        dav/dav_encode.cpp \
  • TabularUnified trunk/source/ndp.cpp

    r61 r63  
    33 *                    http://www.blueprintsoftwareworks.com
    44 * Copyright (c) 2005 Vitali E. Pelenyov
     5 * Copyright (c) 2009 Yuri Dario, netlabs.org
    56 *
    67 * Permission is hereby granted, free of charge, to any person obtaining
     
    3334
    3435#include "resource.hpp"
     36#include "util.hpp"
    3537
    3638const NDPROPERTYINFO Properties[] =
     
    424426    const char *fullpath;
    425427
    426     LOG((ND_LL_DEBUG, "NdpSetPathInfo: conn=%p, pfiSrc = %p, src = %s\r\n", conn, pfi, szPathName));
     428    LOG((ND_LL_DEBUG, ">NdpSetPathInfo: conn=%p, pfiSrc = %p, src = %s\r\n", conn, pfi, szPathName));
    427429
    428430    NdPathInfo pathinfo(&pfi->stat, pel->name, pel->length);
     
    453455        {
    454456            rc = pConn->SetPathInfo (fullpath, &pathinfo);
    455             LOG((ND_LL_DEBUG, "NdpSetPathInfo: rc = %d, conn = %p, path = %s\r\n", rc, conn, szPathName));
    456457            pConn->GetResource()->ReleaseFullPath (fullpath);
    457458        }
    458459    }
     460
     461    LOG((ND_LL_DEBUG, "<NdpSetPathInfo: rc = %d, conn = %p, path = %s\r\n", rc, conn, szPathName));
    459462
    460463    return rc;
     
    11201123   
    11211124    const char *fullpath = pConn->GetResource()->QueryFullPath (szFileName);
    1122      
     1125
     1126    LOG((ND_LL_DEBUG, ">NdpSetFileAttribute: conn=%p: pfi = %p: path = %s\r\n", conn, pfi, szFileName));
     1127
    11231128    if (!fullpath)
    11241129    {
     
    11421147    }
    11431148   
    1144     LOG((ND_LL_DEBUG, "NdpSetFileAttribute: rc = %d, conn=%p: pfi = %p: path = %s\r\n", rc, conn, pfi, szFileName));
     1149    LOG((ND_LL_DEBUG, "<NdpSetFileAttribute: rc = %d, conn=%p: pfi = %p: path = %s\r\n", rc, conn, pfi, szFileName));
    11451150   
    11461151    return rc;
     
    12151220    NdConnection *pConn = (NdConnection *)conn;
    12161221    NdFile *file = (NdFile *)handle;
     1222
     1223    LOG((ND_LL_DEBUG, ">NdpFileSetInfo: conn=%p: pfi = %p\r\n", conn, pfi));
    12171224   
    12181225    NdPathInfo pathinfo(&pfi->stat, file->Name (), file->NameLength ());
    12191226       
    1220     return pConn->SetPathInfo (file->FullName (), &pathinfo);
     1227    int rc = pConn->SetPathInfo (file->FullName (), &pathinfo);
     1228
     1229    LOG((ND_LL_DEBUG, "<NdpFileSetInfo: conn=%p: rc = %d\r\n", conn, rc));
     1230   
     1231    return rc;
    12211232}
    12221233
     
    13761387    size = pstat->cbFile;
    13771388   
    1378     ph->fsphDosDateToUnixTime (pstat->fdateCreation, pstat->ftimeCreation, (ULONG*)&ctime);
    1379     ph->fsphDosDateToUnixTime (pstat->fdateLastWrite, pstat->ftimeLastWrite, (ULONG*)&mtime);
     1389    fsphDosDateToUnixTime (pstat->fdateCreation, pstat->ftimeCreation, (ULONG*)&ctime);
     1390    creationdate = ctime;
     1391    fsphDosDateToUnixTime (pstat->fdateLastWrite, pstat->ftimeLastWrite, (ULONG*)&mtime);
    13801392}
    13811393
     
    14231435void NdPathInfo::toFILESTATUS3L (FILESTATUS3L *pstat)
    14241436{
    1425     ph->fsphUnixTimeToDosDate (ctime, &pstat->fdateCreation, &pstat->ftimeCreation);
    1426     ph->fsphUnixTimeToDosDate (mtime, &pstat->fdateLastWrite, &pstat->ftimeLastWrite);
     1437    fsphUnixTimeToDosDate (ctime, &pstat->fdateCreation, &pstat->ftimeCreation);
     1438    fsphUnixTimeToDosDate (mtime, &pstat->fdateLastWrite, &pstat->ftimeLastWrite);
    14271439    pstat->fdateLastAccess = pstat->fdateLastWrite;
    14281440    pstat->ftimeLastAccess = pstat->ftimeLastWrite;
  • TabularUnified trunk/source/ndp.hpp

    r29 r63  
    33 *                    http://www.blueprintsoftwareworks.com
    44 * Copyright (c) 2005 Vitali E. Pelenyov
     5 * Copyright (c) 2009 Yuri Dario, netlabs.org
    56 *
    67 * Permission is hereby granted, free of charge, to any person obtaining
  • TabularUnified trunk/source/resource.cpp

    r61 r63  
    33 *                    http://www.blueprintsoftwareworks.com
    44 * Copyright (c) 2005 Vitali E. Pelenyov
     5 * Copyright (c) 2009 Yuri Dario, netlabs.org
    56 *
    67 * Permission is hereby granted, free of charge, to any person obtaining
     
    3536#include "ne_nd.h"
    3637#include "version.h"
     38#include "util.hpp"
    3739
    3840#if DEBUG
     
    7173// obtain properties
    7274#define PROPVAL(a) ne_propset_value(results, &querypathinfo_props[a]);
    73 
    74 /* ISO8601: 2001-01-01T12:30:00Z */
    75 #define ISO8601_FORMAT_Z "%04d-%02d-%02dT%02d:%02d:%02dZ"
    76 
    77 /* Returns the time/date GMT, in ISO8601Z-type format: eg
    78  *   2001-01-01T12:30:00Z. */
    79 char *ne_iso8601z_date(time_t localtime) {
    80     FDATE               nddate;
    81     FTIME               ndtime;
    82     char*               ret;
    83 
    84     // adjust time zone offset
    85     localtime += timezone;
    86     // convert to date&time
    87     ph->fsphUnixTimeToDosDate( localtime, &nddate, &ndtime);
    88 
    89     ret = (char*)ne_malloc(21 + 1);
    90     ne_snprintf(ret, 21, ISO8601_FORMAT_Z,
    91                 nddate.year+1980, nddate.month, nddate.day,
    92                 ndtime.hours, ndtime.minutes, ndtime.twosecs*2);
    93 
    94     return ret;
    95 }
    96 
    97 /* Takes an ISO-8601-formatted date string and returns the time_t.
    98  * Returns (time_t)-1 if the parse fails. */
    99 time_t ne_iso8601z_parse(const char *date)
    100 {
    101     NDTIMEDATE ndgmt;
    102     ULONG       t;
    103 
    104     if (sscanf(date, ISO8601_FORMAT_Z,
    105                          &ndgmt.year, &ndgmt.month, &ndgmt.day,
    106                          &ndgmt.hours, &ndgmt.minutes, &ndgmt.seconds) != 6)
    107     {
    108         return (time_t)-1;
    109     }
    110 
    111     // convert to unix time
    112     ph->fsphTimeTimeDate2Unix( &ndgmt, &t);
    113     // adjust time zone offset
    114     t -= timezone;
    115 
    116     return t;
    117 }
    11875
    11976int ResourceInit (void)
     
    666623    if (value)
    667624    {
    668         ppathinfo->ctime = ne_httpdate_parse(value);
     625        ppathinfo->ctime = ne_iso8601z_parse(value);
     626        LOG((ND_LL_DEBUG, "querypathinfo_callback: ctime PROP_CREATIONDATE=%s %d\n", value, ppathinfo->ctime));
     627        ppathinfo->creationdate = ppathinfo->ctime;
     628        LOG((ND_LL_DEBUG, "querypathinfo_callback: creationdate PROP_CREATIONDATE=%s %d\n", value, ppathinfo->creationdate));
    669629    }
    670630   
     
    672632    if (value)
    673633    {
    674         ppathinfo->mtime = ne_httpdate_parse(value);
     634        ppathinfo->mtime = ne_httpdate_parse_localtime(value);
     635        LOG((ND_LL_DEBUG, "querypathinfo_callback: mtime PROP_GETLASTMODIFIED=%s %d\n", value, ppathinfo->mtime));
    675636    }
    676637
     
    680641    {
    681642        ppathinfo->ctime = ne_iso8601z_parse(value);
     643        LOG((ND_LL_DEBUG, "querypathinfo_callback: ctime PROP_SRT_CREATIONTIME=%s %d\n", value, ppathinfo->ctime));
    682644    }
    683645
     
    686648    {
    687649        ppathinfo->mtime = ne_iso8601z_parse(value);
    688     }
    689 
    690     // get creationdate
    691     value = PROPVAL(PROP_CREATIONDATE);
    692     if (value)
    693     {
    694         ppathinfo->creationdate = ne_iso8601z_parse(value);
     650        LOG((ND_LL_DEBUG, "querypathinfo_callback: mtime PROP_SRT_MODIFIEDTIME=%s %d\n", value, ppathinfo->mtime));
    695651    }
    696652
     
    869825        ppathinfo->creationdate >0 ? ppathinfo->creationdate :  time(NULL));
    870826    LOG((ND_LL_DEBUG, "Connection::SetPathInfo: path = %s\r\n", path));
    871     LOG((ND_LL_DEBUG, "Connection::SetPathInfo set time: %s\n", ops[0].value));
    872     LOG((ND_LL_DEBUG, "Connection::SetPathInfo set time: %s\n", ops[1].value));
    873     LOG((ND_LL_DEBUG, "Connection::SetPathInfo ppathinfo->creationdate: %d\n", ppathinfo->creationdate));
     827    LOG((ND_LL_DEBUG, "Connection::SetPathInfo mtime: %s %d\n", ops[0].value, ppathinfo->mtime));
     828    LOG((ND_LL_DEBUG, "Connection::SetPathInfo ctime: %s %d\n", ops[1].value, ppathinfo->ctime));
     829    LOG((ND_LL_DEBUG, "Connection::SetPathInfo creationdate: %s %d\n", ops[2].value, ppathinfo->creationdate));
    874830
    875831    // set properties
     
    878834
    879835    // free res
    880     ne_free( (void*) ops[0].value);
    881     ne_free( (void*) ops[1].value);
    882     ne_free( (void*) ops[2].value);
     836    free( (void*) ops[0].value);
     837    free( (void*) ops[1].value);
     838    free( (void*) ops[2].value);
    883839
    884840    if (rc)
  • TabularUnified trunk/source/resource.hpp

    r34 r63  
    33 *                    http://www.blueprintsoftwareworks.com
    44 * Copyright (c) 2005 Vitali E. Pelenyov
     5 * Copyright (c) 2009 Yuri Dario, netlabs.org
    56 *
    67 * Permission is hereby granted, free of charge, to any person obtaining
Note: See TracChangeset for help on using the changeset viewer.