fix-bug-181764,在共享文件夹重复发送快捷方式到桌面,桌面会闪一下发送的文件

This commit is contained in:
lizhuoan 2023-07-17 16:06:19 +08:00 committed by Yue-Lan
parent 084b93ccaf
commit 5c46ae0564
1 changed files with 16 additions and 1 deletions

View File

@ -76,6 +76,21 @@ void SharedFileLinkOperation::createShareFilesSymbolicLink(QString &srcUri)
}
g_autoptr (GError) error = nullptr;
if(g_file_test(desktopfp.toUtf8().constData(), G_FILE_TEST_EXISTS)) {
error = g_error_new (1, G_IO_ERROR_EXISTS, "%s", QString(tr("The dest file \"%1\" has existed!")).arg(desktopfp).toUtf8().constData());
FileOperationError except;
except.srcUri = m_src_uri;
except.errorType = ET_GIO;
except.isCritical = true;
except.op = FileOpLink;
except.title = tr("Link file error");
except.destDirUri = m_dest_uri;
except.errorStr = error->message;
except.dlgType = ED_WARNING;
Q_EMIT errored(except);
return;
}
GKeyFile* keyfile = g_key_file_new ();
g_key_file_set_value(keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY, "true");
@ -96,7 +111,7 @@ void SharedFileLinkOperation::createShareFilesSymbolicLink(QString &srcUri)
g_key_file_set_value(keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-Peony-CMD", "true");
// 可能会有路径重复的情况,后续需要做异常处理
g_key_file_save_to_file(keyfile, desktopfp.toUtf8().constData(), nullptr);
g_key_file_save_to_file(keyfile, desktopfp.toUtf8().constData(), &error);
if (keyfile) {
g_key_file_free(keyfile);