Commit 7a4d8f57 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msi: Improve tracing.

parent f1d22c0e
......@@ -2070,7 +2070,6 @@ DWORD msi_get_disk_file_size( LPCWSTR filename )
return INVALID_FILE_SIZE;
size = GetFileSize( file, NULL );
TRACE("size is %u\n", size);
CloseHandle( file );
return size;
}
......@@ -2081,7 +2080,7 @@ BOOL msi_file_hash_matches( MSIFILE *file )
MSIFILEHASHINFO hash;
hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO);
r = MsiGetFileHashW( file->TargetPath, 0, &hash );
r = msi_get_filehash( file->TargetPath, &hash );
if (r != ERROR_SUCCESS)
return FALSE;
......@@ -2154,8 +2153,6 @@ static void set_target_path( MSIPACKAGE *package, MSIFILE *file )
{
MSIASSEMBLY *assembly = file->Component->assembly;
TRACE("file %s is named %s\n", debugstr_w(file->File), debugstr_w(file->FileName));
msi_free( file->TargetPath );
if (assembly && !assembly->application)
{
......@@ -2169,7 +2166,7 @@ static void set_target_path( MSIPACKAGE *package, MSIFILE *file )
file->TargetPath = msi_build_directory_name( 2, dir, file->FileName );
}
TRACE("resolves to %s\n", debugstr_w(file->TargetPath));
TRACE("file %s resolves to %s\n", debugstr_w(file->File), debugstr_w(file->TargetPath));
}
static UINT calculate_file_cost( MSIPACKAGE *package )
......@@ -2197,6 +2194,7 @@ static UINT calculate_file_cost( MSIPACKAGE *package )
continue;
}
file_size = msi_get_disk_file_size( file->TargetPath );
TRACE("%s (size %u)\n", debugstr_w(file->TargetPath), file_size);
if (file->Version)
{
......
......@@ -69,34 +69,38 @@ static msi_file_state calculate_install_state( MSIPACKAGE *package, MSIFILE *fil
VS_FIXEDFILEINFO *file_version;
WCHAR *font_version;
msi_file_state state;
DWORD size;
comp->Action = msi_get_component_action( package, comp );
if (comp->Action != INSTALLSTATE_LOCAL || (comp->assembly && comp->assembly->installed))
{
TRACE("file %s is not scheduled for install\n", debugstr_w(file->File));
TRACE("skipping %s (not scheduled for install)\n", debugstr_w(file->File));
return msifs_skipped;
}
if ((comp->assembly && !comp->assembly->application && !comp->assembly->installed) ||
GetFileAttributesW( file->TargetPath ) == INVALID_FILE_ATTRIBUTES)
{
TRACE("file %s is missing\n", debugstr_w(file->File));
TRACE("installing %s (missing)\n", debugstr_w(file->File));
return msifs_missing;
}
if (file->Version)
{
if ((file_version = msi_get_disk_file_version( file->TargetPath )))
{
TRACE("new %s old %u.%u.%u.%u\n", debugstr_w(file->Version),
HIWORD(file_version->dwFileVersionMS),
LOWORD(file_version->dwFileVersionMS),
HIWORD(file_version->dwFileVersionLS),
LOWORD(file_version->dwFileVersionLS));
if (msi_compare_file_versions( file_version, file->Version ) < 0)
{
TRACE("overwriting %s (new version %s old version %u.%u.%u.%u)\n",
debugstr_w(file->File), debugstr_w(file->Version),
HIWORD(file_version->dwFileVersionMS), LOWORD(file_version->dwFileVersionMS),
HIWORD(file_version->dwFileVersionLS), LOWORD(file_version->dwFileVersionLS));
state = msifs_overwrite;
}
else
{
TRACE("destination file version equal or greater, not overwriting\n");
TRACE("keeping %s (new version %s old version %u.%u.%u.%u)\n",
debugstr_w(file->File), debugstr_w(file->Version),
HIWORD(file_version->dwFileVersionMS), LOWORD(file_version->dwFileVersionMS),
HIWORD(file_version->dwFileVersionLS), LOWORD(file_version->dwFileVersionLS));
state = msifs_present;
}
msi_free( file_version );
......@@ -104,37 +108,46 @@ static msi_file_state calculate_install_state( MSIPACKAGE *package, MSIFILE *fil
}
else if ((font_version = msi_font_version_from_file( file->TargetPath )))
{
TRACE("new %s old %s\n", debugstr_w(file->Version), debugstr_w(font_version));
if (msi_compare_font_versions( font_version, file->Version ) < 0)
{
TRACE("overwriting %s (new version %s old version %u.%u.%u.%u)\n",
debugstr_w(file->File), debugstr_w(file->Version),
HIWORD(file_version->dwFileVersionMS), LOWORD(file_version->dwFileVersionMS),
HIWORD(file_version->dwFileVersionLS), LOWORD(file_version->dwFileVersionLS));
state = msifs_overwrite;
}
else
{
TRACE("destination file version equal or greater, not overwriting\n");
TRACE("keeping %s (new version %s old version %u.%u.%u.%u)\n",
debugstr_w(file->File), debugstr_w(file->Version),
HIWORD(file_version->dwFileVersionMS), LOWORD(file_version->dwFileVersionMS),
HIWORD(file_version->dwFileVersionLS), LOWORD(file_version->dwFileVersionLS));
state = msifs_present;
}
msi_free( font_version );
return state;
}
}
if (msi_get_disk_file_size( file->TargetPath ) != file->FileSize)
if ((size = msi_get_disk_file_size( file->TargetPath )) != file->FileSize)
{
TRACE("overwriting %s (old size %u new size %u)\n", debugstr_w(file->File), size, file->FileSize);
return msifs_overwrite;
}
if (file->hash.dwFileHashInfoSize)
{
if (msi_file_hash_matches( file ))
{
TRACE("file hashes match, not overwriting\n");
TRACE("keeping %s (hash match)\n", debugstr_w(file->File));
return msifs_hashmatch;
}
else
{
TRACE("file hashes do not match, overwriting\n");
TRACE("overwriting %s (hash mismatch)\n", debugstr_w(file->File));
return msifs_overwrite;
}
}
/* assume present */
TRACE("keeping %s\n", debugstr_w(file->File));
return msifs_present;
}
......
......@@ -172,7 +172,6 @@ static WCHAR *load_ttf_name_id( const WCHAR *filename, DWORD id )
end:
CloseHandle(handle);
TRACE("Returning %s\n", debugstr_w(ret));
return ret;
}
......
......@@ -4013,48 +4013,24 @@ extern VOID WINAPI MD5Init( MD5_CTX *);
extern VOID WINAPI MD5Update( MD5_CTX *, const unsigned char *, unsigned int );
extern VOID WINAPI MD5Final( MD5_CTX *);
/***********************************************************************
* MsiGetFileHashW [MSI.@]
*/
UINT WINAPI MsiGetFileHashW( LPCWSTR szFilePath, DWORD dwOptions,
PMSIFILEHASHINFO pHash )
UINT msi_get_filehash( const WCHAR *path, MSIFILEHASHINFO *hash )
{
HANDLE handle, mapping;
void *p;
DWORD length;
UINT r = ERROR_FUNCTION_FAILED;
TRACE("%s %08x %p\n", debugstr_w(szFilePath), dwOptions, pHash );
if (!szFilePath)
return ERROR_INVALID_PARAMETER;
if (!*szFilePath)
return ERROR_PATH_NOT_FOUND;
if (dwOptions)
return ERROR_INVALID_PARAMETER;
if (!pHash)
return ERROR_INVALID_PARAMETER;
if (pHash->dwFileHashInfoSize < sizeof *pHash)
return ERROR_INVALID_PARAMETER;
handle = CreateFileW( szFilePath, GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL );
handle = CreateFileW( path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL );
if (handle == INVALID_HANDLE_VALUE)
{
WARN("can't open file %u\n", GetLastError());
return ERROR_FILE_NOT_FOUND;
}
length = GetFileSize( handle, NULL );
if (length)
if ((length = GetFileSize( handle, NULL )))
{
mapping = CreateFileMappingW( handle, NULL, PAGE_READONLY, 0, 0, NULL );
if (mapping)
if ((mapping = CreateFileMappingW( handle, NULL, PAGE_READONLY, 0, 0, NULL )))
{
p = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, length );
if (p)
if ((p = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, length )))
{
MD5_CTX ctx;
......@@ -4063,7 +4039,7 @@ UINT WINAPI MsiGetFileHashW( LPCWSTR szFilePath, DWORD dwOptions,
MD5Final( &ctx );
UnmapViewOfFile( p );
memcpy( pHash->dwData, ctx.digest, sizeof pHash->dwData );
memcpy( hash->dwData, ctx.digest, sizeof(hash->dwData) );
r = ERROR_SUCCESS;
}
CloseHandle( mapping );
......@@ -4072,16 +4048,39 @@ UINT WINAPI MsiGetFileHashW( LPCWSTR szFilePath, DWORD dwOptions,
else
{
/* Empty file -> set hash to 0 */
memset( pHash->dwData, 0, sizeof pHash->dwData );
memset( hash->dwData, 0, sizeof(hash->dwData) );
r = ERROR_SUCCESS;
}
CloseHandle( handle );
return r;
}
/***********************************************************************
* MsiGetFileHashW [MSI.@]
*/
UINT WINAPI MsiGetFileHashW( LPCWSTR szFilePath, DWORD dwOptions,
PMSIFILEHASHINFO pHash )
{
TRACE("%s %08x %p\n", debugstr_w(szFilePath), dwOptions, pHash );
if (!szFilePath)
return ERROR_INVALID_PARAMETER;
if (!*szFilePath)
return ERROR_PATH_NOT_FOUND;
if (dwOptions)
return ERROR_INVALID_PARAMETER;
if (!pHash)
return ERROR_INVALID_PARAMETER;
if (pHash->dwFileHashInfoSize < sizeof *pHash)
return ERROR_INVALID_PARAMETER;
return msi_get_filehash( szFilePath, pHash );
}
/***********************************************************************
* MsiGetFileHashA [MSI.@]
*/
UINT WINAPI MsiGetFileHashA( LPCSTR szFilePath, DWORD dwOptions,
......
......@@ -937,6 +937,7 @@ extern int msi_compare_file_versions(VS_FIXEDFILEINFO *, const WCHAR *) DECLSPEC
extern int msi_compare_font_versions(const WCHAR *, const WCHAR *) DECLSPEC_HIDDEN;
extern DWORD msi_get_disk_file_size(LPCWSTR) DECLSPEC_HIDDEN;
extern BOOL msi_file_hash_matches(MSIFILE *) DECLSPEC_HIDDEN;
extern UINT msi_get_filehash(const WCHAR *, MSIFILEHASHINFO *) DECLSPEC_HIDDEN;
extern LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value ) DECLSPEC_HIDDEN;
extern LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value ) DECLSPEC_HIDDEN;
......
......@@ -888,7 +888,7 @@ static UINT msi_apply_patch_package( MSIPACKAGE *package, const WCHAR *file )
MSIPATCHINFO *patch = NULL;
UINT r = ERROR_SUCCESS;
TRACE("%p %s\n", package, debugstr_w(file));
TRACE("%p, %s\n", package, debugstr_w(file));
r = MSI_OpenDatabaseW( file, MSIDBOPEN_READONLY + MSIDBOPEN_PATCHFILE, &patch_db );
if (r != ERROR_SUCCESS)
......@@ -1003,6 +1003,8 @@ UINT msi_apply_registered_patch( MSIPACKAGE *package, LPCWSTR patch_code )
MSIPATCHINFO *patch_info;
MSISUMMARYINFO *si;
TRACE("%p, %s\n", package, debugstr_w(patch_code));
len = sizeof(patch_file) / sizeof(WCHAR);
r = MsiGetPatchInfoExW( patch_code, package->ProductCode, NULL, package->Context,
INSTALLPROPERTY_LOCALPACKAGEW, patch_file, &len );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment