MCPcopy Index your code
hub / github.com/sitespeedio/sitespeed.io / processMessage

Method processMessage

lib/plugins/rsync/index.js:142–175  ·  view source on GitHub ↗
(message, queue)

Source from the content-addressed store, hash-verified

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}

Callers

nothing calls this directly

Calls 5

makeFunction · 0.85
postMessageMethod · 0.80
errorMethod · 0.80
uploadFunction · 0.70
uploadLatestFilesFunction · 0.70

Tested by

no test coverage detected