csync_vio_local_stat: Win: fetch mtime and size if not previously fetched
authorOlivier Goffart <ogoffart@woboq.com>
Mon, 21 Dec 2015 13:25:30 +0000 (14:25 +0100)
committerOlivier Goffart <ogoffart@woboq.com>
Mon, 21 Dec 2015 13:25:30 +0000 (14:25 +0100)
Since owncloud 2.1, csync_vio_local_stat was optimized because readdir
would already fetch most of the info.  This works for the discovery,
but not later.  And we used this function later for symliks and co.

So this fixes the .lnk on windows

Issue #4300

csync/src/vio/csync_vio_local_win.c
src/libsync/filesystem.cpp

index 80e1228514bcb7e8098f8761b03f9c80eda3b217..7bf403315a399709c188b5c0a0ecf69a324aa21d 100644 (file)
@@ -250,6 +250,17 @@ int csync_vio_local_stat(const char *uri, csync_vio_file_stat_t *buf) {
     /* printf("Index: %I64i\n", FileIndex.QuadPart); */
     buf->inode = FileIndex.QuadPart;
 
+    if (!(buf->fields & CSYNC_VIO_FILE_STAT_FIELDS_SIZE)) {
+        buf->size = (fileInfo.nFileSizeHigh * ((int64_t)(MAXDWORD)+1)) + fileInfo.nFileSizeLow;
+        buf->fields |= CSYNC_VIO_FILE_STAT_FIELDS_SIZE;
+    }
+    if (!(buf->fields & CSYNC_VIO_FILE_STAT_FIELDS_MTIME)) {
+        DWORD rem;
+        buf->mtime = FileTimeToUnixTime(&fileInfo.ftLastWriteTime, &rem);
+        /* CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "Local File MTime: %llu", (unsigned long long) buf->mtime ); */
+        buf->fields |= CSYNC_VIO_FILE_STAT_FIELDS_MTIME;
+    }
+
     c_free_locale_string(wuri);
     CloseHandle(h);
     return 0;
index e28cfde20764348485f6dbc87eb4c038976f5a60..569997925bd1b1d898f1012045e296afb7865214 100644 (file)
@@ -414,7 +414,7 @@ static qint64 getSizeWithCsync(const QString& filename)
             && (stat->fields & CSYNC_VIO_FILE_STAT_FIELDS_SIZE)) {
         result = stat->size;
     } else {
-        qDebug() << "Could not get size time for" << filename << "with csync";
+        qDebug() << "Could not get size for" << filename << "with csync";
     }
     csync_vio_file_stat_destroy(stat);
     return result;