@@ -203,17 +203,17 @@ export default class MigrationJob {
203203 this . script . addonRuntime . createSfdmuPluginJob ( ) ;
204204
205205 // ------------------------------- Internal functions --------------------------------------- //
206- function ___applySpecialTaskOrder ( tasks : Task [ ] , specialOrderToApply : Map < string , string [ ] > ) {
206+ function ___applySpecialTaskOrder ( tasks : Task [ ] , specialOrderToApply : Map < string , string [ ] > ) {
207207 for ( let leftIndex = 0 ; leftIndex < tasks . length - 1 ; leftIndex ++ ) {
208208 const leftTask = tasks [ leftIndex ] ;
209209 for ( let rightIndex = leftIndex + 1 ; rightIndex < tasks . length ; rightIndex ++ ) {
210210 const rightTask = tasks [ rightIndex ] ;
211- const childObjects = specialOrderToApply . get ( rightTask . sObjectName ) ;
211+ const childObjects = specialOrderToApply . get ( rightTask . sObjectName ) ;
212212 if ( childObjects && childObjects . includes ( leftTask . sObjectName ) ) {
213- tasks . splice ( rightIndex , 1 ) ;
214- tasks . splice ( leftIndex , 0 , rightTask ) ;
213+ tasks . splice ( rightIndex , 1 ) ;
214+ tasks . splice ( leftIndex , 0 , rightTask ) ;
215215 }
216- }
216+ }
217217 }
218218 }
219219
@@ -288,7 +288,7 @@ export default class MigrationJob {
288288 // Load mapping files
289289 await this . _loadValueMappingFileAsync ( ) ;
290290
291- if ( this . script . sourceOrg . media == DATA_MEDIA_TYPE . File ) {
291+ if ( this . script . sourceOrg . media == DATA_MEDIA_TYPE . File || this . script . hasUseSourceCSVFile ) {
292292
293293 // Prepare source CSV files
294294 await this . _mergeUserGroupCSVfiles ( ) ;
@@ -958,20 +958,22 @@ export default class MigrationJob {
958958 }
959959
960960 private _copyCSVFilesToSourceSubDir ( ) {
961- this . tasks . forEach ( task => {
962- if ( fs . existsSync ( task . data . csvFilename ) ) {
963- fs . copyFileSync ( task . data . csvFilename , task . data . sourceCsvFilename ) ;
964- }
965- } ) ;
961+ this . tasks . filter ( task => this . script . sourceOrg . isFileMedia || task . scriptObject . useSourceCSVFile )
962+ . forEach ( task => {
963+ if ( fs . existsSync ( task . data . csvFilename ) ) {
964+ fs . copyFileSync ( task . data . csvFilename , task . data . sourceCsvFilename ) ;
965+ }
966+ } ) ;
966967 }
967968
968969 private async _validateAndRepairSourceCSVFiles ( ) : Promise < void > {
969970
970971 let self = this ;
972+ let thisTasks = this . tasks . filter ( task => this . script . sourceOrg . isFileMedia || task . scriptObject . useSourceCSVFile ) ;
971973
972974 // Analyse csv structure
973- for ( let index = 0 ; index < this . tasks . length ; index ++ ) {
974- const task = this . tasks [ index ] ;
975+ for ( let index = 0 ; index < thisTasks . length ; index ++ ) {
976+ const task = thisTasks [ index ] ;
975977 this . csvIssues = this . csvIssues . concat ( await task . validateCSV ( ) ) ;
976978 }
977979
@@ -983,13 +985,13 @@ export default class MigrationJob {
983985 }
984986
985987 // Check and repair the source csvs
986- for ( let index = 0 ; index < this . tasks . length ; index ++ ) {
987- const task = this . tasks [ index ] ;
988+ for ( let index = 0 ; index < thisTasks . length ; index ++ ) {
989+ const task = thisTasks [ index ] ;
988990 this . csvIssues = this . csvIssues . concat ( await task . repairCSV ( this . cachedCSVContent , true ) ) ;
989991 }
990992
991- for ( let index = 0 ; index < this . tasks . length ; index ++ ) {
992- const task = this . tasks [ index ] ;
993+ for ( let index = 0 ; index < thisTasks . length ; index ++ ) {
994+ const task = thisTasks [ index ] ;
993995 this . csvIssues = this . csvIssues . concat ( await task . repairCSV ( this . cachedCSVContent , false ) ) ;
994996 }
995997
0 commit comments