@sasjs/cli 6.1.0 → 6.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -150,13 +150,20 @@
150
150
  writeFiles,
151
151
  clear: clearAll,
152
152
  snapshot: () => askWorker({ type: 'sasjs-snapshot' }, 'sasjs-snapshot'),
153
+ /**
154
+ * The drive total in bytes, measured by the worker: it owns the stored
155
+ * representation, so the figure stays the one `statSync` reports rather than
156
+ * the length of the strings this store happens to hold - which would count
157
+ * the base64 expansion and the marker of a byte entry.
158
+ */
153
159
  stats: async () => {
154
- const files = await readAll()
155
- const paths = Object.keys(files)
156
- return {
157
- files: paths.length,
158
- bytes: paths.reduce((t, p) => t + files[p].length, 0)
159
- }
160
+ const answer = await askWorker({ type: 'sasjs-stats' }, 'sasjs-stats')
161
+ // a worker that cannot report fails the read, as the other drive reads
162
+ // do: a caller destructuring { files, bytes } must not be handed NaN, and
163
+ // neither must a reply of an older shape that carries no stats at all
164
+ if (answer.error) throw new Error(answer.error)
165
+ if (!answer.stats) throw new Error('sasjs-stats reply carried no stats')
166
+ return answer.stats
160
167
  },
161
168
  /**
162
169
  * Downloads the current drive as `mock-snapshot.json`. Drop that file in the