projects
/
claws.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
77f9a0f
)
Fix performance loss on certain file I/O that doesn't need
author
Colin Leroy
<colin@colino.net>
Sun, 7 Oct 2018 13:40:38 +0000
(15:40 +0200)
committer
Colin Leroy
<colin@colino.net>
Sun, 7 Oct 2018 13:49:31 +0000
(15:49 +0200)
to be safe
13 files changed:
src/common/file-utils.c
patch
|
blob
|
history
src/common/file-utils.h
patch
|
blob
|
history
src/compose.c
patch
|
blob
|
history
src/crash.c
patch
|
blob
|
history
src/main.c
patch
|
blob
|
history
src/news.c
patch
|
blob
|
history
src/plugins/fancy/fancy_prefs.c
patch
|
blob
|
history
src/plugins/smime/smime.c
patch
|
blob
|
history
src/plugins/spamassassin/spamassassin.c
patch
|
blob
|
history
src/plugins/vcalendar/vcal_manager.c
patch
|
blob
|
history
src/plugins/vcalendar/vcal_meeting_gtk.c
patch
|
blob
|
history
src/prefs_account.c
patch
|
blob
|
history
src/wizard.c
patch
|
blob
|
history
diff --git
a/src/common/file-utils.c
b/src/common/file-utils.c
index 765f3ef60b3d18f1e4473abc95f84217cabb9317..8f58fece8dc48f259d1e36fa1d79f7475ab7e30f 100644
(file)
--- a/
src/common/file-utils.c
+++ b/
src/common/file-utils.c
@@
-511,10
+511,11
@@
gint canonicalize_file_replace(const gchar *file)
}
}
-gint str_write_to_file(const gchar *str, const gchar *file)
+gint str_write_to_file(const gchar *str, const gchar *file
, gboolean safe
)
{
FILE *fp;
size_t len;
{
FILE *fp;
size_t len;
+ int r;
cm_return_val_if_fail(str != NULL, -1);
cm_return_val_if_fail(file != NULL, -1);
cm_return_val_if_fail(str != NULL, -1);
cm_return_val_if_fail(file != NULL, -1);
@@
-537,7
+538,13
@@
gint str_write_to_file(const gchar *str, const gchar *file)
return -1;
}
return -1;
}
- if (claws_safe_fclose(fp) == EOF) {
+ if (safe) {
+ r = claws_safe_fclose(fp);
+ } else {
+ r = claws_fclose(fp);
+ }
+
+ if (r == EOF) {
FILE_OP_ERROR(file, "claws_fclose");
claws_unlink(file);
return -1;
FILE_OP_ERROR(file, "claws_fclose");
claws_unlink(file);
return -1;
diff --git
a/src/common/file-utils.h
b/src/common/file-utils.h
index 05bcbfb46d0bfe3bbcc6e7d282ee7a3f4563b4a4..10926f055da2177b1dce270a675a52dc07855c7c 100644
(file)
--- a/
src/common/file-utils.h
+++ b/
src/common/file-utils.h
@@
-84,8
+84,6
@@
gint copy_file_part (FILE *fp,
gint canonicalize_file (const gchar *src,
const gchar *dest);
gint canonicalize_file_replace (const gchar *file);
gint canonicalize_file (const gchar *src,
const gchar *dest);
gint canonicalize_file_replace (const gchar *file);
-gint str_write_to_file (const gchar *str,
- const gchar *file);
gchar *file_read_to_str (const gchar *file);
gchar *file_read_to_str_no_recode(const gchar *file);
gchar *file_read_stream_to_str (FILE *fp);
gchar *file_read_to_str (const gchar *file);
gchar *file_read_to_str_no_recode(const gchar *file);
gchar *file_read_stream_to_str (FILE *fp);
@@
-103,6
+101,7
@@
FILE *get_tmpfile_in_dir (const gchar *dir,
gchar **filename);
FILE *str_open_as_stream (const gchar *str);
gint str_write_to_file (const gchar *str,
gchar **filename);
FILE *str_open_as_stream (const gchar *str);
gint str_write_to_file (const gchar *str,
- const gchar *file);
+ const gchar *file,
+ gboolean safe);
#endif
#endif
diff --git
a/src/compose.c
b/src/compose.c
index bf3300773f5554e394ef9312e17dd3ccdde48212..0d8f774f96bcbb90314fa4c7c31cda99278291c8 100644
(file)
--- a/
src/compose.c
+++ b/
src/compose.c
@@
-5904,7
+5904,7
@@
static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
rewind(fp);
content = file_read_stream_to_str(fp);
rewind(fp);
content = file_read_stream_to_str(fp);
- str_write_to_file(content, tmp_enc_file);
+ str_write_to_file(content, tmp_enc_file
, TRUE
);
g_free(content);
/* Now write the unencrypted body. */
g_free(content);
/* Now write the unencrypted body. */
@@
-11674,7
+11674,7
@@
static void compose_insert_drag_received_cb (GtkWidget *widget,
/* Assume a list of no files, and data has ://, is a remote link */
gchar *tmpdata = g_strstrip(g_strdup(ddata));
gchar *tmpfile = get_tmp_file();
/* Assume a list of no files, and data has ://, is a remote link */
gchar *tmpdata = g_strstrip(g_strdup(ddata));
gchar *tmpfile = get_tmp_file();
- str_write_to_file(tmpdata, tmpfile);
+ str_write_to_file(tmpdata, tmpfile
, TRUE
);
g_free(tmpdata);
compose_insert_file(compose, tmpfile);
claws_unlink(tmpfile);
g_free(tmpdata);
compose_insert_file(compose, tmpfile);
claws_unlink(tmpfile);
diff --git
a/src/crash.c
b/src/crash.c
index ae1d4b17356b73585412e3d3d7e5e415c12ae73c..edac5c725ba920d82c57a8569a47ae89f06ea2cf 100644
(file)
--- a/
src/crash.c
+++ b/
src/crash.c
@@
-290,7
+290,7
@@
static void crash_create_debugger_file(void)
{
gchar *filespec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, DEBUGGERRC, NULL);
{
gchar *filespec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, DEBUGGERRC, NULL);
- str_write_to_file(DEBUG_SCRIPT, filespec);
+ str_write_to_file(DEBUG_SCRIPT, filespec
, TRUE
);
g_free(filespec);
}
g_free(filespec);
}
@@
-310,7
+310,7
@@
static void crash_save_crash_log(GtkButton *button, const gchar *text)
strftime(buf, sizeof buf, "claws-crash-log-%Y-%m-%d-%H-%M-%S.txt", lt);
if (NULL != (filename = filesel_select_file_save(_("Save crash information"), buf))
&& *filename)
strftime(buf, sizeof buf, "claws-crash-log-%Y-%m-%d-%H-%M-%S.txt", lt);
if (NULL != (filename = filesel_select_file_save(_("Save crash information"), buf))
&& *filename)
- str_write_to_file(text, filename);
+ str_write_to_file(text, filename
, TRUE
);
g_free(filename);
}
g_free(filename);
}
diff --git
a/src/main.c
b/src/main.c
index 65a3ec16fb1209a7a2f239ea5d5b7ae536e3a06e..0f170165932f04f812498b9ec5e865e8e8e3876c 100644
(file)
--- a/
src/main.c
+++ b/
src/main.c
@@
-1440,7
+1440,7
@@
int main(int argc, char *argv[])
folder_item_update_freeze();
}
/* make the crash-indicator file */
folder_item_update_freeze();
}
/* make the crash-indicator file */
- str_write_to_file("foo", get_crashfile_name());
+ str_write_to_file("foo", get_crashfile_name()
, FALSE
);
inc_autocheck_timer_init(mainwin);
inc_autocheck_timer_init(mainwin);
diff --git
a/src/news.c
b/src/news.c
index 70eb4d6cb0dbd423fb81ffd29a536889bf0a0179..61120c46e8bfba97b7d4acb6ad97aaa308a67e18 100644
(file)
--- a/
src/news.c
+++ b/
src/news.c
@@
-819,7
+819,7
@@
static gint news_get_article(Folder *folder, gint num, gchar *filename)
r = nntp_threaded_article(folder, num, &result, &len);
if (r == NEWSNNTP_NO_ERROR) {
r = nntp_threaded_article(folder, num, &result, &len);
if (r == NEWSNNTP_NO_ERROR) {
- if (str_write_to_file(result, filename) < 0) {
+ if (str_write_to_file(result, filename
, FALSE
) < 0) {
mmap_string_unref(result);
return -1;
}
mmap_string_unref(result);
return -1;
}
diff --git
a/src/plugins/fancy/fancy_prefs.c
b/src/plugins/fancy/fancy_prefs.c
index ce677ee8849b78103d299f3a9891e4266194949f..7c553ba4b24b894007a7e53656952baadb7754ed 100644
(file)
--- a/
src/plugins/fancy/fancy_prefs.c
+++ b/
src/plugins/fancy/fancy_prefs.c
@@
-364,7
+364,7
@@
static void fancy_prefs_stylesheet_edit_cb(GtkWidget *widget, gpointer data)
{
const gchar *stylesheet = gtk_entry_get_text(GTK_ENTRY(data));
if (!is_file_exist(stylesheet))
{
const gchar *stylesheet = gtk_entry_get_text(GTK_ENTRY(data));
if (!is_file_exist(stylesheet))
- str_write_to_file(stylesheet, "");
+ str_write_to_file(stylesheet, ""
, TRUE
);
open_txt_editor(stylesheet, prefs_common_get_ext_editor_cmd());
}
open_txt_editor(stylesheet, prefs_common_get_ext_editor_cmd());
}
diff --git
a/src/plugins/smime/smime.c
b/src/plugins/smime/smime.c
index ea999c11d661dc274619864387442f49f6a189a7..2546343add5a50c51927b1a7d1d624b1b0c4a382 100644
(file)
--- a/
src/plugins/smime/smime.c
+++ b/
src/plugins/smime/smime.c
@@
-286,7
+286,7
@@
static gint smime_check_signature(MimeInfo *mimeinfo)
gchar *tmp_file = get_tmp_file();
MimeInfo *newinfo = NULL, *decinfo = NULL, *parentinfo = NULL;
gchar *tmp_file = get_tmp_file();
MimeInfo *newinfo = NULL, *decinfo = NULL, *parentinfo = NULL;
- str_write_to_file(textstr, tmp_file);
+ str_write_to_file(textstr, tmp_file
, TRUE
);
newinfo = procmime_scan_file(tmp_file);
decinfo = g_node_first_child(newinfo->node) != NULL ?
g_node_first_child(newinfo->node)->data : NULL;
newinfo = procmime_scan_file(tmp_file);
decinfo = g_node_first_child(newinfo->node) != NULL ?
g_node_first_child(newinfo->node)->data : NULL;
diff --git
a/src/plugins/spamassassin/spamassassin.c
b/src/plugins/spamassassin/spamassassin.c
index 0cd725abe8b424c0f44ee41ae4d3f87a4edc0def..e5a39b2e5b227b9daae079ba9f092fe80398f872 100644
(file)
--- a/
src/plugins/spamassassin/spamassassin.c
+++ b/
src/plugins/spamassassin/spamassassin.c
@@
-389,7
+389,7
@@
gchar* spamassassin_create_tmp_spamc_wrapper(gboolean spam)
config.username, config.timeout,
config.max_size * 1024, config.compress?"-z":"",
spam?"spam":"ham");
config.username, config.timeout,
config.max_size * 1024, config.compress?"-z":"",
spam?"spam":"ham");
- if (str_write_to_file(contents, fname) < 0) {
+ if (str_write_to_file(contents, fname
, TRUE
) < 0) {
g_free(fname);
fname = NULL;
}
g_free(fname);
fname = NULL;
}
diff --git
a/src/plugins/vcalendar/vcal_manager.c
b/src/plugins/vcalendar/vcal_manager.c
index 009cdbdbd64108ca70c9a2abe1f8347e347f1da8..fe71bf6d2cbe0ccf1e29773cd5dd31268d3c1591 100644
(file)
--- a/
src/plugins/vcalendar/vcal_manager.c
+++ b/
src/plugins/vcalendar/vcal_manager.c
@@
-502,7
+502,7
@@
gchar *vcal_manager_event_dump(VCalEvent *event, gboolean is_reply, gboolean is_
"\n"
"%s", headers, icalcomponent_as_ical_string(calendar));
"\n"
"%s", headers, icalcomponent_as_ical_string(calendar));
- if (str_write_to_file(body, tmpfile) < 0) {
+ if (str_write_to_file(body, tmpfile
, FALSE
) < 0) {
g_free(tmpfile);
tmpfile = NULL;
}
g_free(tmpfile);
tmpfile = NULL;
}
@@
-640,7
+640,7
@@
gchar *vcal_manager_dateevent_dump(const gchar *uid, FolderItem *item)
"\n"
"%s", headers, lines);
g_free(lines);
"\n"
"%s", headers, lines);
g_free(lines);
- if (str_write_to_file(body, tmpfile) < 0) {
+ if (str_write_to_file(body, tmpfile
, FALSE
) < 0) {
g_free(tmpfile);
tmpfile = NULL;
} else
g_free(tmpfile);
tmpfile = NULL;
} else
@@
-754,7
+754,7
@@
gchar *vcal_manager_icalevent_dump(icalcomponent *event, gchar *orga, icalcompon
"\n"
"%s", headers, qpbody);
"\n"
"%s", headers, qpbody);
- if (str_write_to_file(body, tmpfile) < 0) {
+ if (str_write_to_file(body, tmpfile
, FALSE
) < 0) {
g_free(tmpfile);
tmpfile = NULL;
} else
g_free(tmpfile);
tmpfile = NULL;
} else
diff --git
a/src/plugins/vcalendar/vcal_meeting_gtk.c
b/src/plugins/vcalendar/vcal_meeting_gtk.c
index 8e7dff16790db407bfe750e711da4cca0fd19a01..c5ff05b9ec3d9dc531930882900d884db7297e7b 100644
(file)
--- a/
src/plugins/vcalendar/vcal_meeting_gtk.c
+++ b/
src/plugins/vcalendar/vcal_meeting_gtk.c
@@
-1840,7
+1840,7
@@
void multisync_export(void)
);
vcal_manager_event_dump(event, FALSE, FALSE, calendar, FALSE);
tmp = g_strconcat(path, G_DIR_SEPARATOR_S, file, NULL);
);
vcal_manager_event_dump(event, FALSE, FALSE, calendar, FALSE);
tmp = g_strconcat(path, G_DIR_SEPARATOR_S, file, NULL);
- str_write_to_file(icalcomponent_as_ical_string(calendar), tmp);
+ str_write_to_file(icalcomponent_as_ical_string(calendar), tmp
, TRUE
);
g_free(tmp);
files = g_slist_append(files, file);
vcal_manager_free_event(event);
g_free(tmp);
files = g_slist_append(files, file);
vcal_manager_free_event(event);
@@
-1900,7
+1900,7
@@
gboolean vcal_meeting_export_calendar(const gchar *path,
NULL, ALERT_NOTICE);
return FALSE;
} else {
NULL, ALERT_NOTICE);
return FALSE;
} else {
- str_write_to_file("", tmpfile);
+ str_write_to_file("", tmpfile
, TRUE
);
goto putfile;
}
}
goto putfile;
}
}
@@
-1921,7
+1921,7
@@
gboolean vcal_meeting_export_calendar(const gchar *path,
vcal_manager_free_event(event);
}
vcal_manager_free_event(event);
}
- if (str_write_to_file(icalcomponent_as_ical_string(calendar), internal_file) < 0) {
+ if (str_write_to_file(icalcomponent_as_ical_string(calendar), internal_file
, TRUE
) < 0) {
g_warning("can't export internal cal");
}
g_warning("can't export internal cal");
}
@@
-1934,7
+1934,7
@@
gboolean vcal_meeting_export_calendar(const gchar *path,
}
if (vcalprefs.export_enable || path == NULL) {
}
if (vcalprefs.export_enable || path == NULL) {
- if (str_write_to_file(icalcomponent_as_ical_string(calendar), tmpfile) < 0) {
+ if (str_write_to_file(icalcomponent_as_ical_string(calendar), tmpfile
, TRUE
) < 0) {
alertpanel_error(_("Could not export the calendar."));
g_free(tmpfile);
icalcomponent_free(calendar);
alertpanel_error(_("Could not export the calendar."));
g_free(tmpfile);
icalcomponent_free(calendar);
@@
-2083,14
+2083,14
@@
gboolean vcal_meeting_export_freebusy(const gchar *path, const gchar *user,
icalcomponent_add_component(calendar, vfreebusy);
icalcomponent_add_component(calendar, vfreebusy);
- if (str_write_to_file(icalcomponent_as_ical_string(calendar), internal_file) < 0) {
+ if (str_write_to_file(icalcomponent_as_ical_string(calendar), internal_file
, TRUE
) < 0) {
g_warning("can't export freebusy");
}
g_free(internal_file);
if (vcalprefs.export_freebusy_enable) {
g_warning("can't export freebusy");
}
g_free(internal_file);
if (vcalprefs.export_freebusy_enable) {
- if (str_write_to_file(icalcomponent_as_ical_string(calendar), tmpfile) < 0) {
+ if (str_write_to_file(icalcomponent_as_ical_string(calendar), tmpfile
, TRUE
) < 0) {
alertpanel_error(_("Could not export the freebusy info."));
g_free(tmpfile);
icalcomponent_free(calendar);
alertpanel_error(_("Could not export the freebusy info."));
g_free(tmpfile);
icalcomponent_free(calendar);
diff --git
a/src/prefs_account.c
b/src/prefs_account.c
index 1eb6cee17d029268164b21d69596ee8612cfb01a..5ed582d2b6bb11171ebc7aba72d792c568d1a85e 100644
(file)
--- a/
src/prefs_account.c
+++ b/
src/prefs_account.c
@@
-4557,7
+4557,7
@@
static void prefs_account_signature_edit_cb(GtkWidget *widget, gpointer data)
{
const gchar *sigpath = gtk_entry_get_text(GTK_ENTRY(data));
if (!is_file_exist(sigpath))
{
const gchar *sigpath = gtk_entry_get_text(GTK_ENTRY(data));
if (!is_file_exist(sigpath))
- str_write_to_file(sigpath, "");
+ str_write_to_file(sigpath, ""
, TRUE
);
open_txt_editor(sigpath, prefs_common_get_ext_editor_cmd());
}
open_txt_editor(sigpath, prefs_common_get_ext_editor_cmd());
}
diff --git
a/src/wizard.c
b/src/wizard.c
index a942347bc7d8db67e6f6ab2132663903ec10f094..a3c53dad4b8d883bea5577516fc643334d26570a 100644
(file)
--- a/
src/wizard.c
+++ b/
src/wizard.c
@@
-403,7
+403,7
@@
static void wizard_read_defaults(void)
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "accountrc.tmpl", NULL);
if (!is_file_exist(rcpath)) {
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "accountrc.tmpl", NULL);
if (!is_file_exist(rcpath)) {
- str_write_to_file(accountrc_tmpl, rcpath);
+ str_write_to_file(accountrc_tmpl, rcpath
, TRUE
);
}
prefs_read_config(template_params, "AccountTemplate", rcpath, NULL);
}
prefs_read_config(template_params, "AccountTemplate", rcpath, NULL);
@@
-591,7
+591,7
@@
static void write_welcome_email(WizardWindow *wizard)
msg = g_strconcat(head, body, NULL);
if (inbox && inbox->total_msgs == 0
msg = g_strconcat(head, body, NULL);
if (inbox && inbox->total_msgs == 0
- && str_write_to_file(msg, file) >= 0) {
+ && str_write_to_file(msg, file
, TRUE
) >= 0) {
MsgFlags flags = { MSG_UNREAD|MSG_NEW, 0};
folder_item_add_msg(inbox, file, &flags, FALSE);
}
MsgFlags flags = { MSG_UNREAD|MSG_NEW, 0};
folder_item_add_msg(inbox, file, &flags, FALSE);
}