Commit 6eb7eadf authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

msi: Check the volume name when changing media.

parent 5b8bad75
......@@ -68,10 +68,25 @@ struct media_info {
WCHAR source[MAX_PATH];
};
static BOOL source_matches_volume(struct media_info *mi, LPWSTR source_root)
{
WCHAR volume_name[MAX_PATH + 1];
if (!GetVolumeInformationW(source_root, volume_name, MAX_PATH + 1,
NULL, NULL, NULL, NULL, 0))
{
ERR("Failed to get volume information\n");
return FALSE;
}
return !lstrcmpW(mi->volume_label, volume_name);
}
static UINT msi_change_media( MSIPACKAGE *package, struct media_info *mi )
{
LPSTR msg;
LPWSTR error, error_dialog;
LPWSTR source_dir;
UINT r = ERROR_SUCCESS;
static const WCHAR szUILevel[] = {'U','I','L','e','v','e','l',0};
......@@ -82,8 +97,11 @@ static UINT msi_change_media( MSIPACKAGE *package, struct media_info *mi )
error = generate_error_string( package, 1302, 1, mi->disk_prompt );
error_dialog = msi_dup_property( package, error_prop );
source_dir = msi_dup_property( package, cszSourceDir );
PathStripToRootW(source_dir);
while ( r == ERROR_SUCCESS && GetFileAttributesW( mi->source ) == INVALID_FILE_ATTRIBUTES )
while ( r == ERROR_SUCCESS &&
!source_matches_volume(mi, source_dir) )
{
r = msi_spawn_error_dialog( package, error_dialog, error );
......@@ -97,6 +115,7 @@ static UINT msi_change_media( MSIPACKAGE *package, struct media_info *mi )
msi_free( error );
msi_free( error_dialog );
msi_free( source_dir );
return r;
}
......@@ -572,8 +591,9 @@ static UINT load_media_info(MSIPACKAGE *package, MSIFILE *file, struct media_inf
static UINT ready_media(MSIPACKAGE *package, MSIFILE *file, struct media_info *mi)
{
UINT rc = ERROR_SUCCESS;
BOOL found = FALSE;
UINT rc = ERROR_SUCCESS, type;
BOOL found = TRUE;
LPWSTR source_dir;
/* media info for continuous cabinet is already loaded */
if (mi->is_continuous)
......@@ -586,9 +606,23 @@ static UINT ready_media(MSIPACKAGE *package, MSIFILE *file, struct media_info *m
return ERROR_FUNCTION_FAILED;
}
if (mi->volume_label)
{
source_dir = msi_dup_property(package, cszSourceDir);
PathStripToRootW(source_dir);
type = GetDriveTypeW(source_dir);
if (type == DRIVE_CDROM || type == DRIVE_REMOVABLE)
found = source_matches_volume(mi, source_dir);
msi_free(source_dir);
}
if (file->IsCompressed &&
GetFileAttributesW(mi->source) == INVALID_FILE_ATTRIBUTES)
{
found = FALSE;
if (package->BaseURL && UrlIsW(package->BaseURL, URLIS_URL))
{
rc = download_remote_cabinet(package, mi);
......@@ -598,11 +632,11 @@ static UINT ready_media(MSIPACKAGE *package, MSIFILE *file, struct media_info *m
found = TRUE;
}
}
if (!found)
rc = msi_change_media(package, mi);
}
if (!found)
rc = msi_change_media(package, mi);
return rc;
}
......
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