From 6448e811fb6fde1503db0176a1f161322b1258df Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Mon, 23 Jun 2008 23:41:22 -0500 Subject: [PATCH] * Don't overwrite a file that has a greater or equal version to the source file. --- dlls/msi/files.c | 43 +++++++++++++++++++++++++------------------ 1 files changed, 25 insertions(+), 18 deletions(-) diff --git a/dlls/msi/files.c b/dlls/msi/files.c index c6e70d9..08c1959 100644 --- a/dlls/msi/files.c +++ b/dlls/msi/files.c @@ -459,6 +459,24 @@ done: return ret; } +/* compares the version of a file read from the filesystem and + * the version specified in the File table + */ +static int msi_compare_file_version(MSIFILE *file) +{ + WCHAR version[MAX_PATH]; + DWORD size; + UINT r; + + size = MAX_PATH; + version[0] = '\0'; + r = MsiGetFileVersionW(file->TargetPath, version, &size, NULL, NULL); + if (r != ERROR_SUCCESS) + return 0; + + return lstrcmpW(version, file->Version); +} + void msi_free_media_info( MSIMEDIAINFO *mi ) { msi_free( mi->disk_prompt ); @@ -802,6 +820,13 @@ UINT ACTION_InstallFiles(MSIPACKAGE *package) continue; } + if (MsiGetFileVersionW(file->TargetPath, NULL, NULL, NULL, NULL) == ERROR_SUCCESS && + msi_compare_file_version(file) >= 0) + { + TRACE("Destination file version greater, not overwriting\n"); + continue; + } + if (file->Sequence > mi->last_sequence || mi->is_continuous || (file->IsCompressed && !mi->is_extracted)) { @@ -972,24 +997,6 @@ UINT ACTION_DuplicateFiles(MSIPACKAGE *package) return rc; } -/* compares the version of a file read from the filesystem and - * the version specified in the File table - */ -static int msi_compare_file_version( MSIFILE *file ) -{ - WCHAR version[MAX_PATH]; - DWORD size; - UINT r; - - size = MAX_PATH; - version[0] = '\0'; - r = MsiGetFileVersionW( file->TargetPath, version, &size, NULL, NULL ); - if ( r != ERROR_SUCCESS ) - return 0; - - return lstrcmpW( version, file->Version ); -} - UINT ACTION_RemoveFiles( MSIPACKAGE *package ) { MSIFILE *file; -- 1.5.4.3