msi: Create temp files in the destination directory instead of the root.
This commit is contained in:
parent
9059fee7c5
commit
89472db9e3
|
@ -195,23 +195,25 @@ static UINT copy_install_file(MSIPACKAGE *package, MSIFILE *file, LPWSTR source)
|
||||||
}
|
}
|
||||||
if (gle == ERROR_SHARING_VIOLATION || gle == ERROR_USER_MAPPED_FILE)
|
if (gle == ERROR_SHARING_VIOLATION || gle == ERROR_USER_MAPPED_FILE)
|
||||||
{
|
{
|
||||||
WCHAR tmpfileW[MAX_PATH], *pathW, *p;
|
WCHAR *tmpfileW, *pathW, *p;
|
||||||
DWORD len;
|
DWORD len;
|
||||||
|
|
||||||
TRACE("file in use, scheduling rename operation\n");
|
TRACE("file in use, scheduling rename operation\n");
|
||||||
|
|
||||||
GetTempFileNameW(szBackSlash, szMsi, 0, tmpfileW);
|
if (!(pathW = strdupW( file->TargetPath ))) return ERROR_OUTOFMEMORY;
|
||||||
len = strlenW(file->TargetPath) + strlenW(tmpfileW) + 1;
|
|
||||||
if (!(pathW = msi_alloc(len * sizeof(WCHAR))))
|
|
||||||
return ERROR_OUTOFMEMORY;
|
|
||||||
|
|
||||||
strcpyW(pathW, file->TargetPath);
|
|
||||||
if ((p = strrchrW(pathW, '\\'))) *p = 0;
|
if ((p = strrchrW(pathW, '\\'))) *p = 0;
|
||||||
strcatW(pathW, tmpfileW);
|
len = strlenW( pathW ) + 16;
|
||||||
|
if (!(tmpfileW = msi_alloc(len * sizeof(WCHAR))))
|
||||||
|
{
|
||||||
|
msi_free( pathW );
|
||||||
|
return ERROR_OUTOFMEMORY;
|
||||||
|
}
|
||||||
|
if (!GetTempFileNameW( pathW, szMsi, 0, tmpfileW )) tmpfileW[0] = 0;
|
||||||
|
msi_free( pathW );
|
||||||
|
|
||||||
if (CopyFileW(source, pathW, FALSE) &&
|
if (CopyFileW(source, tmpfileW, FALSE) &&
|
||||||
MoveFileExW(file->TargetPath, NULL, MOVEFILE_DELAY_UNTIL_REBOOT) &&
|
MoveFileExW(file->TargetPath, NULL, MOVEFILE_DELAY_UNTIL_REBOOT) &&
|
||||||
MoveFileExW(pathW, file->TargetPath, MOVEFILE_DELAY_UNTIL_REBOOT))
|
MoveFileExW(tmpfileW, file->TargetPath, MOVEFILE_DELAY_UNTIL_REBOOT))
|
||||||
{
|
{
|
||||||
file->state = msifs_installed;
|
file->state = msifs_installed;
|
||||||
package->need_reboot = 1;
|
package->need_reboot = 1;
|
||||||
|
@ -221,8 +223,9 @@ static UINT copy_install_file(MSIPACKAGE *package, MSIFILE *file, LPWSTR source)
|
||||||
{
|
{
|
||||||
gle = GetLastError();
|
gle = GetLastError();
|
||||||
WARN("failed to schedule rename operation: %d)\n", gle);
|
WARN("failed to schedule rename operation: %d)\n", gle);
|
||||||
|
DeleteFileW( tmpfileW );
|
||||||
}
|
}
|
||||||
msi_free(pathW);
|
msi_free(tmpfileW);
|
||||||
}
|
}
|
||||||
|
|
||||||
return gle;
|
return gle;
|
||||||
|
|
|
@ -458,32 +458,36 @@ static INT_PTR cabinet_copy_file(FDINOTIFICATIONTYPE fdint,
|
||||||
}
|
}
|
||||||
if (err == ERROR_SHARING_VIOLATION || err == ERROR_USER_MAPPED_FILE)
|
if (err == ERROR_SHARING_VIOLATION || err == ERROR_USER_MAPPED_FILE)
|
||||||
{
|
{
|
||||||
WCHAR tmpfileW[MAX_PATH], *tmppathW, *p;
|
WCHAR *tmpfileW, *tmppathW, *p;
|
||||||
DWORD len;
|
DWORD len;
|
||||||
|
|
||||||
TRACE("file in use, scheduling rename operation\n");
|
TRACE("file in use, scheduling rename operation\n");
|
||||||
|
|
||||||
GetTempFileNameW(szBackSlash, szMsi, 0, tmpfileW);
|
if (!(tmppathW = strdupW( path ))) return ERROR_OUTOFMEMORY;
|
||||||
len = strlenW(path) + strlenW(tmpfileW) + 1;
|
|
||||||
if (!(tmppathW = msi_alloc(len * sizeof(WCHAR))))
|
|
||||||
return ERROR_OUTOFMEMORY;
|
|
||||||
|
|
||||||
strcpyW(tmppathW, path);
|
|
||||||
if ((p = strrchrW(tmppathW, '\\'))) *p = 0;
|
if ((p = strrchrW(tmppathW, '\\'))) *p = 0;
|
||||||
strcatW(tmppathW, tmpfileW);
|
len = strlenW( tmppathW ) + 16;
|
||||||
|
if (!(tmpfileW = msi_alloc(len * sizeof(WCHAR))))
|
||||||
|
{
|
||||||
|
msi_free( tmppathW );
|
||||||
|
return ERROR_OUTOFMEMORY;
|
||||||
|
}
|
||||||
|
if (!GetTempFileNameW(tmppathW, szMsi, 0, tmpfileW)) tmpfileW[0] = 0;
|
||||||
|
msi_free( tmppathW );
|
||||||
|
|
||||||
handle = CreateFileW(tmppathW, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, attrs, NULL);
|
handle = CreateFileW(tmpfileW, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, attrs, NULL);
|
||||||
|
|
||||||
if (handle != INVALID_HANDLE_VALUE &&
|
if (handle != INVALID_HANDLE_VALUE &&
|
||||||
MoveFileExW(path, NULL, MOVEFILE_DELAY_UNTIL_REBOOT) &&
|
MoveFileExW(path, NULL, MOVEFILE_DELAY_UNTIL_REBOOT) &&
|
||||||
MoveFileExW(tmppathW, path, MOVEFILE_DELAY_UNTIL_REBOOT))
|
MoveFileExW(tmpfileW, path, MOVEFILE_DELAY_UNTIL_REBOOT))
|
||||||
{
|
{
|
||||||
data->package->need_reboot = 1;
|
data->package->need_reboot = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
WARN("failed to schedule rename operation %s (error %d)\n", debugstr_w(path), GetLastError());
|
WARN("failed to schedule rename operation %s (error %d)\n", debugstr_w(path), GetLastError());
|
||||||
|
DeleteFileW( tmpfileW );
|
||||||
msi_free(tmppathW);
|
}
|
||||||
|
msi_free(tmpfileW);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
WARN("failed to create %s (error %d)\n", debugstr_w(path), err);
|
WARN("failed to create %s (error %d)\n", debugstr_w(path), err);
|
||||||
|
|
Loading…
Reference in New Issue