@tobos/cli 0.4.21 → 0.4.22

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.
Files changed (2) hide show
  1. package/dist/cli.js +8 -6
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -89,7 +89,7 @@ function settings() {
89
89
  }
90
90
 
91
91
  // src/api.ts
92
- var VERSION = true ? "0.4.21" : "dev";
92
+ var VERSION = true ? "0.4.22" : "dev";
93
93
  function newer(a, b) {
94
94
  const parse = (v) => /^\d+\.\d+\.\d+/.test(v) ? v.split(".").map((n) => parseInt(n)) : null;
95
95
  const x = parse(a);
@@ -424,10 +424,12 @@ async function syncMediaJson(root) {
424
424
  async function uploadMedia(root, media, server, deck, note) {
425
425
  const hashes = [...new Set(Object.values(media).map((m) => m.hash))];
426
426
  if (hashes.length === 0) return [];
427
- const { missing } = await api("/api/media/missing", {
428
- body: { hashes },
429
- server
430
- });
427
+ const { missing, elsewhere = 0 } = await api(
428
+ "/api/media/missing",
429
+ { body: { hashes, deck }, server }
430
+ );
431
+ const sizes = Object.fromEntries(Object.values(media).map((m) => [m.hash, m.size]));
432
+ const shows = Object.values(sizes).reduce((sum, size) => sum + size, 0) - elsewhere;
431
433
  const uploaded = [];
432
434
  for (const hash of missing) {
433
435
  const [name, entry] = Object.entries(media).find(([, m]) => m.hash === hash);
@@ -437,7 +439,7 @@ async function uploadMedia(root, media, server, deck, note) {
437
439
  `media/${name} is on a slide but not on this machine, and the server doesn't have it: put it in media/, then push again.`
438
440
  );
439
441
  note(`uploading media/${name} (${Math.round(entry.size / 1e3)} kB)`);
440
- const response = await request(`/api/media/${hash}?deck=${deck}`, {
442
+ const response = await request(`/api/media/${hash}?deck=${deck}&shows=${shows}`, {
441
443
  method: "PUT",
442
444
  body: Readable.toWeb(createReadStream(path)),
443
445
  contentType: entry.type,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tobos/cli",
3
- "version": "0.4.21",
3
+ "version": "0.4.22",
4
4
  "description": "The command line of Tobos: https://tobos.ai",
5
5
  "type": "module",
6
6
  "license": "FSL-1.1-ALv2",