msi: Simplify ready_media.

This commit is contained in:
James Hawkins 2007-11-15 02:58:21 -06:00 committed by Alexandre Julliard
parent a97d6556a4
commit bb747e4fbe
1 changed files with 26 additions and 28 deletions

View File

@ -596,9 +596,7 @@ 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, type;
BOOL found = TRUE;
LPWSTR source_dir;
UINT rc = ERROR_SUCCESS;
/* media info for continuous cabinet is already loaded */
if (mi->is_continuous)
@ -611,41 +609,41 @@ static UINT ready_media(MSIPACKAGE *package, MSIFILE *file, struct media_info *m
return ERROR_FUNCTION_FAILED;
}
/* package should be downloaded */
if (file->IsCompressed &&
GetFileAttributesW(mi->source) == INVALID_FILE_ATTRIBUTES &&
package->BaseURL && UrlIsW(package->BaseURL, URLIS_URL))
{
return download_remote_cabinet(package, mi);
}
/* check volume matches, change media if not */
if (mi->volume_label && mi->disk_id > 1)
{
source_dir = msi_dup_property(package, cszSourceDir);
PathStripToRootW(source_dir);
type = GetDriveTypeW(source_dir);
LPWSTR source = msi_dup_property(package, cszSourceDir);
BOOL matches;
UINT type;
if (type == DRIVE_CDROM || type == DRIVE_REMOVABLE)
found = source_matches_volume(mi, source_dir);
PathStripToRootW(source);
type = GetDriveTypeW(source);
matches = source_matches_volume(mi, source);
msi_free(source);
if (!found)
found = GetFileAttributesW(mi->cabinet) != INVALID_FILE_ATTRIBUTES;
msi_free(source_dir);
}
if (file->IsCompressed &&
GetFileAttributesW(mi->source) == INVALID_FILE_ATTRIBUTES)
if ((type == DRIVE_CDROM || type == DRIVE_REMOVABLE) && !matches)
{
found = FALSE;
if (package->BaseURL && UrlIsW(package->BaseURL, URLIS_URL))
{
rc = download_remote_cabinet(package, mi);
if (rc == ERROR_SUCCESS &&
GetFileAttributesW(mi->source) != INVALID_FILE_ATTRIBUTES)
{
found = TRUE;
}
}
}
if (!found)
rc = msi_change_media(package, mi);
if (rc != ERROR_SUCCESS)
return rc;
}
}
if (mi->cabinet && GetFileAttributesW(mi->cabinet) == INVALID_FILE_ATTRIBUTES)
{
ERR("Cabinet not found: %s\n", debugstr_w(mi->cabinet));
return ERROR_INSTALL_FAILURE;
}
return ERROR_SUCCESS;
}
static UINT get_file_target(MSIPACKAGE *package, LPCWSTR file_key,