Commit ad4f747f authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msi: Fix changing media for normal files.

parent 4ce176af
...@@ -331,7 +331,7 @@ UINT ACTION_InstallFiles(MSIPACKAGE *package) ...@@ -331,7 +331,7 @@ UINT ACTION_InstallFiles(MSIPACKAGE *package)
if (!file->Component->Enabled) continue; if (!file->Component->Enabled) continue;
if (file->state != msifs_hashmatch && if (file->state != msifs_hashmatch &&
(rc = ready_media( package, file->Sequence, file->IsCompressed, mi ))) (rc = ready_media( package, file->IsCompressed, mi )))
{ {
ERR("Failed to ready media for %s\n", debugstr_w(file->File)); ERR("Failed to ready media for %s\n", debugstr_w(file->File));
goto done; goto done;
...@@ -512,7 +512,7 @@ UINT ACTION_PatchFiles( MSIPACKAGE *package ) ...@@ -512,7 +512,7 @@ UINT ACTION_PatchFiles( MSIPACKAGE *package )
{ {
MSICABDATA data; MSICABDATA data;
rc = ready_media( package, patch->Sequence, TRUE, mi ); rc = ready_media( package, TRUE, mi );
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
{ {
ERR("Failed to ready media for %s\n", debugstr_w(file->File)); ERR("Failed to ready media for %s\n", debugstr_w(file->File));
......
...@@ -838,79 +838,71 @@ static UINT find_published_source(MSIPACKAGE *package, MSIMEDIAINFO *mi) ...@@ -838,79 +838,71 @@ static UINT find_published_source(MSIPACKAGE *package, MSIMEDIAINFO *mi)
return ERROR_FUNCTION_FAILED; return ERROR_FUNCTION_FAILED;
} }
UINT ready_media(MSIPACKAGE *package, UINT Sequence, BOOL IsCompressed, MSIMEDIAINFO *mi) UINT ready_media( MSIPACKAGE *package, BOOL compressed, MSIMEDIAINFO *mi )
{ {
UINT rc = ERROR_SUCCESS; UINT rc;
WCHAR *cabinet_file; WCHAR *cabinet_file = NULL;
/* media info for continuous cabinet is already loaded */ /* media info for continuous cabinet is already loaded */
if (mi->is_continuous) if (mi->is_continuous) return ERROR_SUCCESS;
return ERROR_SUCCESS;
if (mi->cabinet)
{
/* cabinet is internal, no checks needed */ /* cabinet is internal, no checks needed */
if (!mi->cabinet || mi->cabinet[0] == '#') if (mi->cabinet[0] == '#') return ERROR_SUCCESS;
return ERROR_SUCCESS;
cabinet_file = get_cabinet_filename(mi); if (!(cabinet_file = get_cabinet_filename( mi ))) return ERROR_OUTOFMEMORY;
/* package should be downloaded */ /* package should be downloaded */
if (IsCompressed && if (compressed && GetFileAttributesW( cabinet_file ) == INVALID_FILE_ATTRIBUTES &&
GetFileAttributesW(cabinet_file) == INVALID_FILE_ATTRIBUTES && package->BaseURL && UrlIsW( package->BaseURL, URLIS_URL ))
package->BaseURL && UrlIsW(package->BaseURL, URLIS_URL))
{ {
WCHAR temppath[MAX_PATH], *p; WCHAR temppath[MAX_PATH], *p;
rc = msi_download_file(cabinet_file, temppath); if ((rc = msi_download_file( cabinet_file, temppath )) != ERROR_SUCCESS)
if (rc != ERROR_SUCCESS)
{ {
ERR("Failed to download %s (%u)\n", debugstr_w(cabinet_file), rc); ERR("failed to download %s (%u)\n", debugstr_w(cabinet_file), rc);
msi_free(cabinet_file); msi_free( cabinet_file );
return rc; return rc;
} }
if ((p = strrchrW(temppath, '\\'))) *p = 0; if ((p = strrchrW( temppath, '\\' ))) *p = 0;
strcpyW(mi->sourcedir, temppath); strcpyW( mi->sourcedir, temppath );
PathAddBackslashW(mi->sourcedir); PathAddBackslashW( mi->sourcedir );
msi_free(mi->cabinet); msi_free( mi->cabinet );
mi->cabinet = strdupW(p + 1); mi->cabinet = strdupW( p + 1 );
msi_free( cabinet_file );
msi_free(cabinet_file);
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
}
/* check volume matches, change media if not */ /* check volume matches, change media if not */
if (mi->volume_label && mi->disk_id > 1 && if (mi->volume_label && mi->disk_id > 1 && strcmpW( mi->first_volume, mi->volume_label ))
strcmpW( mi->first_volume, mi->volume_label ))
{ {
LPWSTR source = msi_dup_property(package->db, szSourceDir); WCHAR *source = msi_dup_property( package->db, szSourceDir );
BOOL matches; BOOL match = source_matches_volume( mi, source );
msi_free( source );
matches = source_matches_volume(mi, source);
msi_free(source);
if ((mi->type == DRIVE_CDROM || mi->type == DRIVE_REMOVABLE) && !matches) if (!match && (mi->type == DRIVE_CDROM || mi->type == DRIVE_REMOVABLE))
{ {
rc = msi_change_media(package, mi); if ((rc = msi_change_media( package, mi )) != ERROR_SUCCESS)
if (rc != ERROR_SUCCESS)
{ {
msi_free(cabinet_file); msi_free( cabinet_file );
return rc; return rc;
} }
} }
} }
if (mi->cabinet)
if (IsCompressed &&
GetFileAttributesW(cabinet_file) == INVALID_FILE_ATTRIBUTES)
{ {
rc = find_published_source(package, mi); if (compressed && GetFileAttributesW( cabinet_file ) == INVALID_FILE_ATTRIBUTES)
if (rc != ERROR_SUCCESS)
{ {
ERR("Cabinet not found: %s\n", debugstr_w(cabinet_file)); if ((rc = find_published_source( package, mi )) != ERROR_SUCCESS)
msi_free(cabinet_file); {
ERR("cabinet not found: %s\n", debugstr_w(cabinet_file));
msi_free( cabinet_file );
return ERROR_INSTALL_FAILURE; return ERROR_INSTALL_FAILURE;
} }
} }
}
msi_free(cabinet_file); msi_free( cabinet_file );
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
......
...@@ -1041,7 +1041,7 @@ typedef struct ...@@ -1041,7 +1041,7 @@ typedef struct
PVOID user; PVOID user;
} MSICABDATA; } MSICABDATA;
extern UINT ready_media(MSIPACKAGE *package, UINT Sequence, BOOL IsCompressed, MSIMEDIAINFO *mi) DECLSPEC_HIDDEN; extern UINT ready_media(MSIPACKAGE *package, BOOL compressed, MSIMEDIAINFO *mi) DECLSPEC_HIDDEN;
extern UINT msi_load_media_info(MSIPACKAGE *package, UINT Sequence, MSIMEDIAINFO *mi) DECLSPEC_HIDDEN; extern UINT msi_load_media_info(MSIPACKAGE *package, UINT Sequence, MSIMEDIAINFO *mi) DECLSPEC_HIDDEN;
extern void msi_free_media_info(MSIMEDIAINFO *mi) DECLSPEC_HIDDEN; extern void msi_free_media_info(MSIMEDIAINFO *mi) DECLSPEC_HIDDEN;
extern BOOL msi_cabextract(MSIPACKAGE* package, MSIMEDIAINFO *mi, LPVOID data) DECLSPEC_HIDDEN; extern BOOL msi_cabextract(MSIPACKAGE* package, MSIMEDIAINFO *mi, LPVOID data) DECLSPEC_HIDDEN;
......
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