(message, queue)
| 140 | this.storageManager = context.storageManager; |
| 141 | } |
| 142 | async processMessage(message, queue) { |
| 143 | if (message.type === 'sitespeedio.setup') { |
| 144 | // Let other plugins know that the rsync plugin is alive |
| 145 | queue.postMessage(this.make('rsync.setup')); |
| 146 | } else if (message.type === 'html.finished') { |
| 147 | const make = this.make; |
| 148 | const baseDir = this.storageManager.getBaseDir(); |
| 149 | |
| 150 | log.info(`Uploading ${baseDir} using rsync, this can take a while ...`); |
| 151 | |
| 152 | try { |
| 153 | await upload( |
| 154 | baseDir, |
| 155 | this.rsyncOptions, |
| 156 | this.storageManager.getStoragePrefix() |
| 157 | ); |
| 158 | if (this.options.copyLatestFilesToBase) { |
| 159 | const rootPath = path.resolve(baseDir, '..'); |
| 160 | const prefix = this.storageManager.getStoragePrefix(); |
| 161 | const firstPart = prefix.split('/')[0]; |
| 162 | await uploadLatestFiles(rootPath, this.rsyncOptions, firstPart); |
| 163 | } |
| 164 | log.info('Finished upload using rsync'); |
| 165 | if (this.rsyncOptions.removeLocalResult) { |
| 166 | fs.rmSync(baseDir, { recursive: true }); |
| 167 | log.debug(`Removed local files and directory ${baseDir}`); |
| 168 | } |
| 169 | } catch (error) { |
| 170 | queue.postMessage(make('error', error)); |
| 171 | log.error('Could not upload using rsync', error); |
| 172 | } |
| 173 | queue.postMessage(make('rsync.finished')); |
| 174 | } |
| 175 | } |
| 176 | } |
nothing calls this directly
no test coverage detected