Make sure the TEMP path is *not* replaced when running the web-update tool, as this will prevent the updater from working correctly.

This commit is contained in:
LoRd_MuldeR 2013-11-25 02:20:44 +01:00
parent 0bc1157906
commit f3ae451b32
4 changed files with 30 additions and 22 deletions

View File

@ -35,7 +35,7 @@
#define VER_LAMEXP_MINOR_LO 9
#define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 8
#define VER_LAMEXP_BUILD 1472
#define VER_LAMEXP_BUILD 1473
#define VER_LAMEXP_CONFG 1348
///////////////////////////////////////////////////////////////////////////////

View File

@ -387,7 +387,7 @@ void UpdateDialog::applyUpdate(void)
QStringList args;
QEventLoop loop;
lamexp_init_process(process, QFileInfo(m_binaryUpdater).absolutePath());
lamexp_init_process(process, QFileInfo(m_binaryUpdater).absolutePath(), false);
connect(&process, SIGNAL(error(QProcess::ProcessError)), &loop, SLOT(quit()));
connect(&process, SIGNAL(finished(int,QProcess::ExitStatus)), &loop, SLOT(quit()));
@ -409,6 +409,7 @@ void UpdateDialog::applyUpdate(void)
m_updaterProcess = lamexp_process_id(&process);
loop.exec(QEventLoop::ExcludeUserInputEvents);
}
m_updaterProcess = NULL;
QApplication::restoreOverrideCursor();

View File

@ -175,7 +175,7 @@ const lamexp_os_version_t &lamexp_get_os_version(void);
void lamexp_init_console(const QStringList &argv);
void lamexp_init_error_handlers(void);
int lamexp_init_ipc(void);
void lamexp_init_process(QProcess &process, const QString &wokringDir);
void lamexp_init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir = true);
bool lamexp_init_qt(int argc, char* argv[]);
bool lamexp_install_translator(const QString &language);
bool lamexp_install_translator_from_file(const QString &qmFile);

View File

@ -192,38 +192,45 @@ void lamexp_temp_folder_clear(void)
/*
* Setup QPorcess object
*/
void lamexp_init_process(QProcess &process, const QString &wokringDir)
void lamexp_init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir)
{
//Environment variable names
static const char *const s_envvar_names[] =
static const char *const s_envvar_names_temp[] =
{
"TEMP", "TMP", "TMPDIR", "HOME", "USERPROFILE", "HOMEPATH", NULL
};
static const char *const s_envvar_names_remove[] =
{
"WGETRC", "SYSTEM_WGETRC", "HTTP_PROXY", "FTP_PROXY", "NO_PROXY", "GNUPGHOME", "LC_ALL", "LC_COLLATE", "LC_CTYPE", "LC_MESSAGES", "LC_MONETARY", "LC_NUMERIC", "LC_TIME", "LANG", NULL
};
const QString tempDir = QDir::toNativeSeparators(lamexp_temp_folder2());
//Initialize environment
QProcessEnvironment env = process.processEnvironment();
if(env.isEmpty()) env = QProcessEnvironment::systemEnvironment();
//Setup TEMP directory
env.insert("TEMP", tempDir);
env.insert("TMP", tempDir);
env.insert("TMPDIR", tempDir);
env.insert("HOME", tempDir);
env.insert("USERPROFILE", tempDir);
env.insert("HOMEPATH", tempDir);
//Clean a number of enviroment variables that might affect our tools
for(size_t i = 0; s_envvar_names_remove[i]; i++)
{
env.remove(QString::fromLatin1(s_envvar_names_remove[i]));
env.remove(QString::fromLatin1(s_envvar_names_remove[i]).toLower());
}
const QString tempDir = QDir::toNativeSeparators(lamexp_temp_folder2());
//Replace TEMP directory in environment
if(bReplaceTempDir)
{
for(size_t i = 0; s_envvar_names_temp[i]; i++)
{
env.insert(s_envvar_names_temp[i], tempDir);
}
}
//Setup PATH variable
const QString path = env.value("PATH", QString());
const QString path = env.value("PATH", QString()).trimmed();
env.insert("PATH", path.isEmpty() ? tempDir : QString("%1;%2").arg(tempDir, path));
//Clean a number of enviroment variables that might affect our tools
for(size_t i = 0; s_envvar_names[i]; i++)
{
env.remove(QString::fromLatin1(s_envvar_names[i]));
env.remove(QString::fromLatin1(s_envvar_names[i]).toLower());
}
//Setup QPorcess object
process.setWorkingDirectory(wokringDir);
process.setProcessChannelMode(QProcess::MergedChannels);
process.setReadChannel(QProcess::StandardOutput);