Commit 91bde62b authored by Jehan's avatar Jehan

plug-ins: make mail more robust.

I got a 'Invalid cross-device link' error (errno 18) on my system. Let's
add some redundancy and try g_file_move() if g_rename() failed.
This at least fixed my case.
parent f22290e0
Pipeline #105383 failed with stages
in 8 minutes and 55 seconds
......@@ -439,7 +439,27 @@ send_image (const gchar *filename,
filepath = g_build_filename (gimp_file_get_utf8_name (tmp_dir),
mail_info.filename, NULL);
g_rename (tmpname, filepath);
if (g_rename (tmpname, filepath) == -1)
{
/* But on some system, I got an 'Invalid cross-device link' errno
* with g_rename().
* On the other hand, g_file_move() seems to be more robust.
*/
GFile *source = g_file_new_for_path (tmpname);
GFile *target = g_file_new_for_path (filepath);
if (! g_file_move (source, target, G_FILE_COPY_NONE, NULL, NULL, NULL, &error))
{
g_message ("%s", error->message);
g_clear_error (&error);
g_object_unref (source);
g_object_unref (target);
goto error;
}
g_object_unref (source);
g_object_unref (target);
}
mailcmd[0] = g_strdup ("xdg-email");
mailcmd[1] = "--attach";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment