@@ -63,46 +63,7 @@ module.exports = class Task{
6363 }
6464
6565 initialize ( done , additionalSteps = [ ] ) {
66- async . series ( additionalSteps . concat ( [
67- // Handle post-processing options logic
68- cb => {
69- // If we need to post process results
70- // if pc-ept is supported (build entwine point cloud)
71- // we automatically add the pc-ept option to the task options by default
72- if ( this . skipPostProcessing ) cb ( ) ;
73- else {
74- odmInfo . supportsOption ( "pc-ept" , ( err , supported ) => {
75- if ( err ) {
76- console . warn ( `Cannot check for supported option pc-ept: ${ err } ` ) ;
77- } else if ( supported ) {
78- if ( ! this . options . find ( opt => opt . name === "pc-ept" ) ) {
79- this . options . push ( { name : 'pc-ept' , value : true } ) ;
80- }
81- }
82- cb ( ) ;
83- } ) ;
84- }
85- } ,
86-
87- cb => {
88- // If we need to post process results
89- // if cog is supported (build cloud optimized geotiffs)
90- // we automatically add the cog option to the task options by default
91- if ( this . skipPostProcessing ) cb ( ) ;
92- else {
93- odmInfo . supportsOption ( "cog" , ( err , supported ) => {
94- if ( err ) {
95- console . warn ( `Cannot check for supported option cog: ${ err } ` ) ;
96- } else if ( supported ) {
97- if ( ! this . options . find ( opt => opt . name === "cog" ) ) {
98- this . options . push ( { name : 'cog' , value : true } ) ;
99- }
100- }
101- cb ( ) ;
102- } ) ;
103- }
104- } ,
105-
66+ async . series ( additionalSteps . concat ( this . setPostProcessingOptsSteps ( ) , [
10667 // Read images info
10768 cb => {
10869 fs . readdir ( this . getImagesFolderPath ( ) , ( err , files ) => {
@@ -150,6 +111,48 @@ module.exports = class Task{
150111 } ) ;
151112 }
152113
114+ setPostProcessingOptsSteps ( ) {
115+ return [
116+ cb => {
117+ // If we need to post process results
118+ // if pc-ept is supported (build entwine point cloud)
119+ // we automatically add the pc-ept option to the task options by default
120+ if ( this . skipPostProcessing ) cb ( ) ;
121+ else {
122+ odmInfo . supportsOption ( "pc-ept" , ( err , supported ) => {
123+ if ( err ) {
124+ console . warn ( `Cannot check for supported option pc-ept: ${ err } ` ) ;
125+ } else if ( supported ) {
126+ if ( ! this . options . find ( opt => opt . name === "pc-ept" ) ) {
127+ this . options . push ( { name : 'pc-ept' , value : true } ) ;
128+ }
129+ }
130+ cb ( ) ;
131+ } ) ;
132+ }
133+ } ,
134+
135+ cb => {
136+ // If we need to post process results
137+ // if cog is supported (build cloud optimized geotiffs)
138+ // we automatically add the cog option to the task options by default
139+ if ( this . skipPostProcessing ) cb ( ) ;
140+ else {
141+ odmInfo . supportsOption ( "cog" , ( err , supported ) => {
142+ if ( err ) {
143+ console . warn ( `Cannot check for supported option cog: ${ err } ` ) ;
144+ } else if ( supported ) {
145+ if ( ! this . options . find ( opt => opt . name === "cog" ) ) {
146+ this . options . push ( { name : 'cog' , value : true } ) ;
147+ }
148+ }
149+ cb ( ) ;
150+ } ) ;
151+ }
152+ }
153+ ] ;
154+ }
155+
153156 static CreateFromSerialized ( taskJson , done ) {
154157 const task = new Task ( taskJson . uuid ,
155158 taskJson . name ,
@@ -617,17 +620,25 @@ module.exports = class Task{
617620 restart ( options , cb ) {
618621 if ( ! this . initialized && this . status . code === statusCodes . CANCELED ) {
619622 this . setStatus ( statusCodes . RUNNING ) ;
620- if ( options !== undefined ) this . options = options ;
621- cb ( null ) ;
623+ if ( options !== undefined ) {
624+ this . options = options ;
625+ async . series ( this . setPostProcessingOptsSteps ( ) , cb ) ;
626+ } else {
627+ cb ( ) ;
628+ }
622629 } else if ( [ statusCodes . CANCELED , statusCodes . FAILED , statusCodes . COMPLETED ] . indexOf ( this . status . code ) !== - 1 ) {
623630 this . setStatus ( statusCodes . QUEUED ) ;
624631 this . dateCreated = new Date ( ) . getTime ( ) ;
625632 this . dateStarted = 0 ;
626633 this . output = [ ] ;
627634 this . progress = 0 ;
628635 this . stopTrackingProcessingTime ( true ) ;
629- if ( options !== undefined ) this . options = options ;
630- cb ( null ) ;
636+ if ( options !== undefined ) {
637+ this . options = options ;
638+ async . series ( this . setPostProcessingOptsSteps ( ) , cb ) ;
639+ } else {
640+ cb ( ) ;
641+ }
631642 } else {
632643 cb ( new Error ( "Task cannot be restarted" ) ) ;
633644 }
0 commit comments