Commit 5352d099 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

msi: Create parent directories when duplicating files if they don't exist, with tests.

parent 837588c6
...@@ -901,6 +901,7 @@ static UINT ITERATE_DuplicateFiles(MSIRECORD *row, LPVOID param) ...@@ -901,6 +901,7 @@ static UINT ITERATE_DuplicateFiles(MSIRECORD *row, LPVOID param)
} }
dest = build_directory_name(2, dest_path, dest_name); dest = build_directory_name(2, dest_path, dest_name);
create_full_pathW(dest);
TRACE("Duplicating file %s to %s\n",debugstr_w(file->TargetPath), TRACE("Duplicating file %s to %s\n",debugstr_w(file->TargetPath),
debugstr_w(dest)); debugstr_w(dest));
......
...@@ -112,6 +112,7 @@ static const CHAR install_exec_seq_dat[] = "Action\tCondition\tSequence\n" ...@@ -112,6 +112,7 @@ static const CHAR install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
"ResolveSource\t\t950\n" "ResolveSource\t\t950\n"
"MoveFiles\t\t1700\n" "MoveFiles\t\t1700\n"
"InstallFiles\t\t4000\n" "InstallFiles\t\t4000\n"
"DuplicateFiles\t\t4500\n"
"InstallServices\t\t5000\n" "InstallServices\t\t5000\n"
"InstallFinalize\t\t6600\n" "InstallFinalize\t\t6600\n"
"InstallInitialize\t\t1500\n" "InstallInitialize\t\t1500\n"
...@@ -559,6 +560,22 @@ static const CHAR mc_file_hash_dat[] = "File_\tOptions\tHashPart1\tHashPart2\tHa ...@@ -559,6 +560,22 @@ static const CHAR mc_file_hash_dat[] = "File_\tOptions\tHashPart1\tHashPart2\tHa
"MsiFileHash\tFile_\n" "MsiFileHash\tFile_\n"
"caesar\t0\t850433704\t-241429251\t675791761\t-1221108824"; "caesar\t0\t850433704\t-241429251\t675791761\t-1221108824";
static const CHAR df_directory_dat[] = "Directory\tDirectory_Parent\tDefaultDir\n"
"s72\tS72\tl255\n"
"Directory\tDirectory\n"
"THIS\tMSITESTDIR\tthis\n"
"DOESNT\tTHIS\tdoesnt\n"
"NONEXISTENT\tDOESNT\texist\n"
"MSITESTDIR\tProgramFilesFolder\tmsitest\n"
"ProgramFilesFolder\tTARGETDIR\t.\n"
"TARGETDIR\t\tSourceDir";
static const CHAR df_duplicate_file_dat[] = "FileKey\tComponent_\tFile_\tDestName\tDestFolder\n"
"s72\ts72\ts72\tS255\tS72\n"
"DuplicateFile\tFileKey\n"
"maximus\tmaximus\tmaximus\taugustus\t\n"
"caesar\tmaximus\tmaximus\t\tNONEXISTENT\n";
typedef struct _msi_table typedef struct _msi_table
{ {
const CHAR *filename; const CHAR *filename;
...@@ -834,6 +851,19 @@ static const msi_table mc_tables[] = ...@@ -834,6 +851,19 @@ static const msi_table mc_tables[] =
ADD_TABLE(mc_file_hash), ADD_TABLE(mc_file_hash),
}; };
static const msi_table df_tables[] =
{
ADD_TABLE(rof_component),
ADD_TABLE(df_directory),
ADD_TABLE(rof_feature),
ADD_TABLE(rof_feature_comp),
ADD_TABLE(rof_file),
ADD_TABLE(install_exec_seq),
ADD_TABLE(rof_media),
ADD_TABLE(property),
ADD_TABLE(df_duplicate_file),
};
/* cabinet definitions */ /* cabinet definitions */
/* make the max size large so there is only one cab file */ /* make the max size large so there is only one cab file */
...@@ -3568,6 +3598,33 @@ static void test_missingcab(void) ...@@ -3568,6 +3598,33 @@ static void test_missingcab(void)
DeleteFile(msifile); DeleteFile(msifile);
} }
static void test_duplicatefiles(void)
{
UINT r;
CreateDirectoryA("msitest", NULL);
create_file("msitest\\maximus", 500);
create_database(msifile, df_tables, sizeof(df_tables) / sizeof(msi_table));
MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
/* fails if the destination folder is not a valid property */
r = MsiInstallProductA(msifile, NULL);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
ok(delete_pf("msitest\\augustus", TRUE), "File not duplicated\n");
ok(delete_pf("msitest\\this\\doesnt\\exist\\maximus", TRUE), "File not duplicated\n");
ok(delete_pf("msitest\\this\\doesnt\\exist", FALSE), "File not duplicated\n");
ok(delete_pf("msitest\\this\\doesnt", FALSE), "File not duplicated\n");
ok(delete_pf("msitest\\this", FALSE), "File not duplicated\n");
ok(delete_pf("msitest", FALSE), "File not installed\n");
DeleteFile("msitest\\maximus");
RemoveDirectory("msitest");
DeleteFile(msifile);
}
START_TEST(install) START_TEST(install)
{ {
DWORD len; DWORD len;
...@@ -3609,6 +3666,7 @@ START_TEST(install) ...@@ -3609,6 +3666,7 @@ START_TEST(install)
test_removefiles(); test_removefiles();
test_movefiles(); test_movefiles();
test_missingcab(); test_missingcab();
test_duplicatefiles();
SetCurrentDirectoryA(prev_path); SetCurrentDirectoryA(prev_path);
} }
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