mirror of
https://github.com/reactos/reactos.git
synced 2024-10-01 23:14:53 +00:00
[0.4.7][SETUPAPI] Apply fix for CORE-12616 PR-408
This fixes a regression introduced in SVN r73442 == git7e9b3d61c0
Our setup created undesired temporary files and left them in the temp folder. Also we saw a slight one-time-increase in memory consumption. This patch was the work of Carlo Bramini He proposed the fix on 2016-12-30 already. I ported this fix from 0.4.8-RC-22-gdba2f743c5
which is what we used successfully from 0.4.8rls-0.4.10rls but does NOT reflect the latest additions yet to restore lastError that were added by Pierre in 0.4.11-dev-643-g8236bb8f38
but even without that few additional lines the patch did 100% what it promised: fixing CORE-12616
This commit is contained in:
parent
ca2308d54c
commit
be84e3f4e5
|
@ -987,24 +987,23 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style,
|
||||||
{
|
{
|
||||||
BOOL rc = FALSE;
|
BOOL rc = FALSE;
|
||||||
BOOL docopy = TRUE;
|
BOOL docopy = TRUE;
|
||||||
WCHAR TempFile[MAX_PATH];
|
#ifdef __REACTOS__
|
||||||
INT hSource, hTemp;
|
INT hSource, hTemp;
|
||||||
OFSTRUCT OfStruct;
|
OFSTRUCT OfStruct;
|
||||||
WCHAR TempPath[MAX_PATH];
|
WCHAR TempPath[MAX_PATH];
|
||||||
|
WCHAR TempFile[MAX_PATH];
|
||||||
|
LONG lRes;
|
||||||
|
#endif
|
||||||
|
|
||||||
TRACE("copy %s to %s style 0x%x\n",debugstr_w(source),debugstr_w(target),style);
|
TRACE("copy %s to %s style 0x%x\n",debugstr_w(source),debugstr_w(target),style);
|
||||||
|
|
||||||
|
#ifdef __REACTOS__
|
||||||
/* Get a temp file name */
|
/* Get a temp file name */
|
||||||
if (!GetTempPathW(sizeof(TempPath) / sizeof(WCHAR), TempPath))
|
if (!GetTempPathW(ARRAYSIZE(TempPath), TempPath))
|
||||||
{
|
{
|
||||||
ERR("GetTempPathW error\n");
|
ERR("GetTempPathW error\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!GetTempFileNameW(TempPath, L"", 0, TempFile))
|
|
||||||
{
|
|
||||||
ERR("GetTempFileNameW(%s) error\n", debugstr_w(TempPath));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Try to open the source file */
|
/* Try to open the source file */
|
||||||
hSource = LZOpenFileW((LPWSTR)source, &OfStruct, OF_READ);
|
hSource = LZOpenFileW((LPWSTR)source, &OfStruct, OF_READ);
|
||||||
|
@ -1014,26 +1013,47 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!GetTempFileNameW(TempPath, L"", 0, TempFile))
|
||||||
|
{
|
||||||
|
ERR("GetTempFileNameW(%s) error\n", debugstr_w(TempPath));
|
||||||
|
|
||||||
|
/* Close the source handle */
|
||||||
|
LZClose(hSource);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Extract the compressed file to a temp location */
|
/* Extract the compressed file to a temp location */
|
||||||
hTemp = LZOpenFileW(TempFile, &OfStruct, OF_CREATE);
|
hTemp = LZOpenFileW(TempFile, &OfStruct, OF_CREATE);
|
||||||
if (hTemp < 0)
|
if (hTemp < 0)
|
||||||
{
|
{
|
||||||
DWORD dwLastError = GetLastError();
|
|
||||||
|
|
||||||
ERR("LZOpenFileW(2) error %d %s\n", (int)hTemp, debugstr_w(TempFile));
|
ERR("LZOpenFileW(2) error %d %s\n", (int)hTemp, debugstr_w(TempFile));
|
||||||
|
|
||||||
/* Close the source handle */
|
/* Close the source handle */
|
||||||
LZClose(hSource);
|
LZClose(hSource);
|
||||||
|
|
||||||
/* Restore error condition triggered by LZOpenFileW */
|
/* Delete temp file if an error is signaled */
|
||||||
SetLastError(dwLastError);
|
DeleteFileW(TempFile);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
LZCopy(hSource, hTemp);
|
lRes = LZCopy(hSource, hTemp);
|
||||||
|
|
||||||
LZClose(hSource);
|
LZClose(hSource);
|
||||||
LZClose(hTemp);
|
LZClose(hTemp);
|
||||||
|
|
||||||
|
if (lRes < 0)
|
||||||
|
{
|
||||||
|
ERR("LZCopy error %d (%s, %s)\n", (int)lRes, debugstr_w(source), debugstr_w(TempFile));
|
||||||
|
|
||||||
|
/* Delete temp file if copy was not successful */
|
||||||
|
DeleteFileW(TempFile);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* before copy processing */
|
/* before copy processing */
|
||||||
if (style & SP_COPY_REPLACEONLY)
|
if (style & SP_COPY_REPLACEONLY)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue