@@ -18,7 +18,6 @@ const {
18
18
const { memoizedTraceSVG, notMemoizedtraceSVG } = require ( `./trace-svg` )
19
19
const duotone = require ( `./duotone` )
20
20
const { IMAGE_PROCESSING_JOB_NAME } = require ( `./gatsby-worker` )
21
- const { createProgress } = require ( `./utils` )
22
21
23
22
const imageSizeCache = new Map ( )
24
23
const getImageSize = file => {
@@ -36,46 +35,6 @@ const getImageSize = file => {
36
35
}
37
36
}
38
37
39
- let progressBar
40
- let pendingImagesCounter = 0
41
- let firstPass = true
42
- const createOrGetProgressBar = reporter => {
43
- if ( ! progressBar ) {
44
- progressBar = createProgress ( `Generating image thumbnails` , reporter )
45
-
46
- const originalDoneFn = progressBar . done
47
-
48
- // TODO this logic should be moved to the reporter.
49
- // when done is called we remove the progressbar instance and reset all the things
50
- // this will be called onPostBuild or when devserver is created
51
- progressBar . done = ( ) => {
52
- originalDoneFn . call ( progressBar )
53
- progressBar = null
54
- pendingImagesCounter = 0
55
- }
56
-
57
- // when we create a progressBar for the second time so when .done() has been called before
58
- // we create a modified tick function that automatically stops the progressbar when total is reached
59
- // this is used for development as we're watching for changes
60
- if ( ! firstPass ) {
61
- let progressBarCurrentValue = 0
62
- const originalTickFn = progressBar . tick
63
- progressBar . tick = ( ticks = 1 ) => {
64
- originalTickFn . call ( progressBar , ticks )
65
- progressBarCurrentValue += ticks
66
-
67
- if ( progressBarCurrentValue === pendingImagesCounter ) {
68
- progressBar . done ( )
69
- }
70
- }
71
- }
72
- firstPass = false
73
- }
74
-
75
- return progressBar
76
- }
77
- exports . getProgressBar = ( ) => progressBar
78
-
79
38
// Bound action creators should be set when passed to onPreInit in gatsby-node.
80
39
// ** It is NOT safe to just directly require the gatsby module **.
81
40
// There is no guarantee that the module resolved is the module executing!
@@ -148,16 +107,6 @@ function prepareQueue({ file, args }) {
148
107
}
149
108
150
109
function createJob ( job , { reporter } ) {
151
- const progressBar = createOrGetProgressBar ( reporter )
152
-
153
- if ( pendingImagesCounter === 0 ) {
154
- progressBar . start ( )
155
- }
156
-
157
- const transformsCount = job . args . operations . length
158
- pendingImagesCounter += transformsCount
159
- progressBar . total = pendingImagesCounter
160
-
161
110
// Jobs can be duplicates and usually are long running tasks.
162
111
// Because of that we shouldn't use async/await and instead opt to use
163
112
// .then() /.catch() handlers, because this allows V8 to release
@@ -169,16 +118,12 @@ function createJob(job, { reporter }) {
169
118
if ( boundActionCreators . createJobV2 ) {
170
119
promise = boundActionCreators . createJobV2 ( job )
171
120
} else {
172
- promise = scheduleJob ( job , boundActionCreators )
121
+ promise = scheduleJob ( job , boundActionCreators , reporter )
173
122
}
174
123
175
- promise
176
- . catch ( err => {
177
- reporter . panic ( err )
178
- } )
179
- . then ( ( ) => {
180
- progressBar . tick ( transformsCount )
181
- } )
124
+ promise . catch ( err => {
125
+ reporter . panic ( err )
126
+ } )
182
127
183
128
return promise
184
129
}
0 commit comments