mirror of
https://github.com/reactos/reactos.git
synced 2024-11-20 06:15:26 +00:00
[0.4.10] [SETUPAPI] Apply yet uncommitted fix for CORE-12616 PR-408
This commit was *not* committed to master yet.
I'll leave the ticket unresolved until it'll be.
This fixes a regression introduced in SVN r73442:
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.
There are ongoing discussions about an alternative approach
to the initial problem that SVN r73442 tried to address.
Serge Gautherie can and shall evaluate that alternative later in dev.
For now many thanks to Carlo Bramini for this fix.
like in last release
(cherry picked from commit dba2f743c5
)
This commit is contained in:
parent
419aabfd90
commit
10a84f3e97
1 changed files with 26 additions and 10 deletions
|
@ -1067,6 +1067,7 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style,
|
|||
OFSTRUCT OfStruct;
|
||||
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);
|
||||
|
@ -1078,11 +1079,6 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style,
|
|||
ERR("GetTempPathW error\n");
|
||||
return FALSE;
|
||||
}
|
||||
if (!GetTempFileNameW(TempPath, L"", 0, TempFile))
|
||||
{
|
||||
ERR("GetTempFileNameW(%s) error\n", debugstr_w(TempPath));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Try to open the source file */
|
||||
hSource = LZOpenFileW((LPWSTR)source, &OfStruct, OF_READ);
|
||||
|
@ -1092,25 +1088,45 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style,
|
|||
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 */
|
||||
hTemp = LZOpenFileW(TempFile, &OfStruct, OF_CREATE);
|
||||
if (hTemp < 0)
|
||||
{
|
||||
DWORD dwLastError = GetLastError();
|
||||
|
||||
ERR("LZOpenFileW(2) error %d %s\n", (int)hTemp, debugstr_w(TempFile));
|
||||
|
||||
/* Close the source handle */
|
||||
LZClose(hSource);
|
||||
|
||||
/* Restore error condition triggered by LZOpenFileW */
|
||||
SetLastError(dwLastError);
|
||||
/* Delete temp file if an error is signaled */
|
||||
DeleteFileW(TempFile);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LZCopy(hSource, hTemp);
|
||||
lRes = LZCopy(hSource, hTemp);
|
||||
|
||||
LZClose(hSource);
|
||||
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 */
|
||||
|
|
Loading…
Reference in a new issue