msi [8/11]: Store the base URL of the MSI package if it is downloaded

James Hawkins truiken at gmail.com
Tue Nov 7 17:13:47 CST 2006


Hi,

This fixes a regression with MSI packages that are hosted on the internet.

Changelog:
* Store the base URL of the MSI package if it is downloaded.

 dlls/msi/files.c   |    2 +-
 dlls/msi/helpers.c |    1 +
 dlls/msi/msipriv.h |    3 ++-
 dlls/msi/package.c |   16 ++++++++++++++--
 dlls/msi/preview.c |    2 +-
 5 files changed, 19 insertions(+), 5 deletions(-)

-- 
James Hawkins
-------------- next part --------------
diff --git a/dlls/msi/files.c b/dlls/msi/files.c
index 4bede98..1195116 100644
--- a/dlls/msi/files.c
+++ b/dlls/msi/files.c
@@ -532,7 +532,7 @@ static UINT ready_media_for_file( MSIPAC
 
         /* only download the remote cabinet file if a local copy does not exist */
         if (GetFileAttributesW(mi->source) == INVALID_FILE_ATTRIBUTES &&
-            UrlIsW(package->PackagePath, URLIS_URL))
+            UrlIsW(package->BaseURL, URLIS_URL))
         {
             rc = msi_extract_remote_cabinet(package, mi);
         }
diff --git a/dlls/msi/helpers.c b/dlls/msi/helpers.c
index acb0f77..490e181 100644
--- a/dlls/msi/helpers.c
+++ b/dlls/msi/helpers.c
@@ -591,6 +591,7 @@ void ACTION_free_package_structures( MSI
         msi_free(package->script);
     }
 
+    msi_free(package->BaseURL);
     msi_free(package->PackagePath);
     msi_free(package->ProductCode);
     msi_free(package->ActionFormat);
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index 8fe25d6..44e9170 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -228,6 +228,7 @@ typedef struct tagMSIPACKAGE
 
     struct list RunningActions;
 
+    LPWSTR BaseURL;
     LPWSTR PackagePath;
     LPWSTR ProductCode;
 
@@ -620,7 +621,7 @@ extern UINT VIEW_find_column( MSIVIEW *,
 extern UINT MSI_SetInstallLevel( MSIPACKAGE *package, int iInstallLevel );
 
 /* package internals */
-extern MSIPACKAGE *MSI_CreatePackage( MSIDATABASE * );
+extern MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *, LPWSTR );
 extern UINT MSI_OpenPackageW( LPCWSTR szPackage, MSIPACKAGE ** );
 extern UINT MSI_SetTargetPathW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
 extern UINT MSI_SetPropertyW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index 3aaad69..1455c6d 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -428,7 +428,7 @@ static UINT msi_get_word_count( MSIPACKA
     return word_count;
 }
 
-MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db )
+MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPWSTR base_url )
 {
     static const WCHAR szLevel[] = { 'U','I','L','e','v','e','l',0 };
     static const WCHAR szpi[] = {'%','i',0};
@@ -466,6 +466,7 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABA
 
         package->WordCount = msi_get_word_count( package );
         package->PackagePath = strdupW( db->path );
+        package->BaseURL = strdupW( base_url );
 
         /* OK, here is where we do a slew of things to the database to 
          * prep for all that is to come as a package */
@@ -550,6 +551,7 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage,
     MSIDATABASE *db = NULL;
     MSIPACKAGE *package;
     MSIHANDLE handle;
+    LPWSTR ptr, base_url = NULL;
     UINT r;
 
     static const WCHAR OriginalDatabase[] =
@@ -571,7 +573,16 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage,
         LPCWSTR file;
 
         if ( UrlIsW( szPackage, URLIS_URL ) )
+        {
             file = msi_download_file( szPackage, temppath );
+
+            base_url = strdupW( szPackage );
+            if ( !base_url )
+                return ERROR_OUTOFMEMORY;
+
+            ptr = strrchrW( base_url, '/' );
+            if (ptr) *(ptr + 1) = '\0';
+        }
         else
             file = copy_package_to_temp( szPackage, temppath );
 
@@ -589,7 +600,8 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage,
         }
     }
 
-    package = MSI_CreatePackage( db );
+    package = MSI_CreatePackage( db, base_url );
+    msi_free( base_url );
     msiobj_release( &db->hdr );
     if( !package )
         return ERROR_FUNCTION_FAILED;
diff --git a/dlls/msi/preview.c b/dlls/msi/preview.c
index 4f4cc5c..ddf0a7a 100644
--- a/dlls/msi/preview.c
+++ b/dlls/msi/preview.c
@@ -43,7 +43,7 @@ MSIPREVIEW *MSI_EnableUIPreview( MSIDATA
     MSIPREVIEW *preview = NULL;
     MSIPACKAGE *package;
 
-    package = MSI_CreatePackage( db );
+    package = MSI_CreatePackage( db, NULL );
     if( package )
     {
         preview = alloc_msiobject( MSIHANDLETYPE_PREVIEW, sizeof (MSIPREVIEW),
-- 
1.4.2.4


More information about the wine-patches mailing list