[Commits] [SCM] claws branch, master, updated. 3.15.0-158-gefd5c57

ticho at claws-mail.org ticho at claws-mail.org
Sat Oct 28 14:53:41 CEST 2017


The branch, master has been updated
       via  efd5c578268bdb7732734240e796d63c178a875f (commit)
      from  3f84a59b732d8a5de35a2300b7dd89fff4898ed0 (commit)

Summary of changes:
 src/procheader.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)


- Log -----------------------------------------------------------------
commit efd5c578268bdb7732734240e796d63c178a875f
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sat Oct 28 14:49:47 2017 +0200

    Avoid use of stat() in procheader_parse_file() on Windows.
    
    Since GLib on different Windows versions has different
    ideas about sizes of struct stat field sizes and is
    inconsistent about it on 64-bit systems, we take advice
    from GLib's own gstdio.h, and use GIO API to get file
    attributes instead.
    
    This will likely have to be changed for all uses of
    stat() or g_stat() elsewhere.
    
    All this to stop Claws Mail showing "1GB" size for all
    emails in summaryview on 64-bit Win10.

diff --git a/src/procheader.c b/src/procheader.c
index 6d5132d..d261642 100644
--- a/src/procheader.c
+++ b/src/procheader.c
@@ -403,16 +403,43 @@ void procheader_get_header_fields(FILE *fp, HeaderEntry hentry[])
 MsgInfo *procheader_parse_file(const gchar *file, MsgFlags flags,
 			       gboolean full, gboolean decrypted)
 {
+#ifdef G_OS_WIN32
+	GFile *f;
+	GFileInfo *fi;
+	GTimeVal tv;
+	GError *error = NULL;
+#else
 	GStatBuf s;
+#endif
 	FILE *fp;
 	MsgInfo *msginfo;
 
+#ifdef G_OS_WIN32
+	f = g_file_new_for_path(file);
+	fi = g_file_query_info(f, "standard::size,standard::type,time::modified",
+			G_FILE_QUERY_INFO_NONE, NULL, &error);
+	if (error != NULL) {
+		g_warning(error->message);
+		g_error_free(error);
+		g_object_unref(f);
+	}
+#else
 	if (g_stat(file, &s) < 0) {
 		FILE_OP_ERROR(file, "stat");
 		return NULL;
 	}
+#endif
+
+#ifdef G_OS_WIN32
+	if (g_file_info_get_file_type(fi) != G_FILE_TYPE_REGULAR) {
+		g_object_unref(fi);
+		g_object_unref(f);
+		return NULL;
+	}
+#else
 	if (!S_ISREG(s.st_mode))
 		return NULL;
+#endif
 
 	if ((fp = g_fopen(file, "rb")) == NULL) {
 		FILE_OP_ERROR(file, "fopen");
@@ -423,10 +450,21 @@ MsgInfo *procheader_parse_file(const gchar *file, MsgFlags flags,
 	fclose(fp);
 
 	if (msginfo) {
+#ifdef G_OS_WIN32
+		msginfo->size = g_file_info_get_size(fi);
+		g_file_info_get_modification_time(fi, &tv);
+		msginfo->mtime = tv.tv_sec;
+#else
 		msginfo->size = s.st_size;
 		msginfo->mtime = s.st_mtime;
+#endif
 	}
 
+#ifdef G_OS_WIN32
+	g_object_unref(fi);
+	g_object_unref(f);
+#endif
+
 	return msginfo;
 }
 

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list