Commit 2ae7f2ae authored by Sébastien Blin's avatar Sébastien Blin
Browse files

chatview: avoid to erase files with a new transfer

Change-Id: I0cfd9bca1d77a4ab52eda092457d86e7c132d201
Gitlab: #890
parent 17211dcf
......@@ -25,6 +25,7 @@
// std
#include <algorithm>
#include <fstream>
// GTK
#include <glib/gi18n.h>
......@@ -248,9 +249,13 @@ webkit_chat_container_script_dialog(GtkWidget* webview, gchar *interaction, Chat
// get full path
std::string filename = current_value.empty()? default_download_dir.c_str() : download_directory_value;
if (!filename.empty() && filename.back() != '/') filename += "/";
filename += info.displayName;
model->acceptTransfer(priv->conversation_->uid, interactionId, filename);
auto wantedFilename = filename + info.displayName;
auto duplicate = 0;
while (std::ifstream(wantedFilename).good()) {
wantedFilename = filename + "(" + std::to_string(duplicate) + ")" + info.displayName;
++duplicate;
}
model->acceptTransfer(priv->conversation_->uid, interactionId, wantedFilename);
} catch (...) {
// ignore
}
......
Supports Markdown
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