@gallop.software/studio 2.3.38 → 2.3.40

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.
@@ -1512,12 +1512,12 @@ async function handleRenameStream(request) {
1512
1512
  if (hasLocalItem) {
1513
1513
  await fs6.rename(absoluteOldPath, absoluteNewPath);
1514
1514
  const imagesDir = getPublicPath("/images");
1515
- const oldThumbFolder = path6.join(imagesDir, oldRelativePath);
1515
+ const oldThumbFolder2 = path6.join(imagesDir, oldRelativePath);
1516
1516
  const newThumbFolder = path6.join(imagesDir, newRelativePath);
1517
1517
  try {
1518
- await fs6.access(oldThumbFolder);
1518
+ await fs6.access(oldThumbFolder2);
1519
1519
  await fs6.mkdir(path6.dirname(newThumbFolder), { recursive: true });
1520
- await fs6.rename(oldThumbFolder, newThumbFolder);
1520
+ await fs6.rename(oldThumbFolder2, newThumbFolder);
1521
1521
  } catch {
1522
1522
  }
1523
1523
  }
@@ -1597,7 +1597,9 @@ async function handleRenameStream(request) {
1597
1597
  });
1598
1598
  }
1599
1599
  await saveMeta(meta);
1600
- await deleteEmptyFolders(getPublicPath());
1600
+ await deleteEmptyFolders(absoluteOldPath);
1601
+ const oldThumbFolder = path6.join(getPublicPath("/images"), oldRelativePath);
1602
+ await deleteEmptyFolders(oldThumbFolder);
1601
1603
  sendEvent({ type: "complete", renamed, newPath });
1602
1604
  controller.close();
1603
1605
  return;
@@ -1827,9 +1829,77 @@ async function handleMoveStream(request) {
1827
1829
  });
1828
1830
  continue;
1829
1831
  }
1832
+ let hasLocalItem = false;
1830
1833
  try {
1831
1834
  await fs6.access(absolutePath);
1835
+ hasLocalItem = true;
1832
1836
  } catch {
1837
+ const folderPrefix = oldKey + "/";
1838
+ const hasChildrenInMeta = Object.keys(meta).some((key) => key.startsWith(folderPrefix));
1839
+ if (hasChildrenInMeta) {
1840
+ const itemsToMove = [];
1841
+ for (const [key, metaEntry] of Object.entries(meta)) {
1842
+ if (key.startsWith(folderPrefix) && metaEntry && typeof metaEntry === "object") {
1843
+ const relativePath = key.slice(folderPrefix.length);
1844
+ const destNewKey = newKey + "/" + relativePath;
1845
+ itemsToMove.push({ oldKey: key, newKey: destNewKey, entry: metaEntry });
1846
+ }
1847
+ }
1848
+ for (const item of itemsToMove) {
1849
+ const itemEntry = item.entry;
1850
+ const isItemInCloud = itemEntry.c !== void 0;
1851
+ const itemCdnUrl = isItemInCloud ? cdnUrls[itemEntry.c] : void 0;
1852
+ const isItemInR2 = isItemInCloud && itemCdnUrl === r2PublicUrl;
1853
+ const itemHasThumbnails = isProcessed(itemEntry);
1854
+ if (isItemInR2) {
1855
+ try {
1856
+ const itemLocalPath = getPublicPath(item.newKey);
1857
+ const buffer = await downloadFromCdn(item.oldKey);
1858
+ await fs6.mkdir(path6.dirname(itemLocalPath), { recursive: true });
1859
+ await fs6.writeFile(itemLocalPath, buffer);
1860
+ if (itemHasThumbnails) {
1861
+ const oldThumbPaths = getAllThumbnailPaths(item.oldKey);
1862
+ const newThumbPaths = getAllThumbnailPaths(item.newKey);
1863
+ for (let t = 0; t < oldThumbPaths.length; t++) {
1864
+ try {
1865
+ const thumbBuffer = await downloadFromCdn(oldThumbPaths[t]);
1866
+ const newThumbLocalPath = getPublicPath(newThumbPaths[t]);
1867
+ await fs6.mkdir(path6.dirname(newThumbLocalPath), { recursive: true });
1868
+ await fs6.writeFile(newThumbLocalPath, thumbBuffer);
1869
+ } catch {
1870
+ }
1871
+ }
1872
+ }
1873
+ await deleteFromCdn(item.oldKey, itemHasThumbnails);
1874
+ await uploadOriginalToCdn(item.newKey);
1875
+ if (itemHasThumbnails) {
1876
+ await uploadToCdn(item.newKey);
1877
+ }
1878
+ try {
1879
+ await fs6.unlink(itemLocalPath);
1880
+ } catch {
1881
+ }
1882
+ if (itemHasThumbnails) {
1883
+ await deleteLocalThumbnails(item.newKey);
1884
+ }
1885
+ } catch (err) {
1886
+ console.error(`Failed to move cloud item ${item.oldKey}:`, err);
1887
+ }
1888
+ }
1889
+ delete meta[item.oldKey];
1890
+ meta[item.newKey] = itemEntry;
1891
+ }
1892
+ moved.push(itemPath);
1893
+ sendEvent({
1894
+ type: "progress",
1895
+ current: i + 1,
1896
+ total,
1897
+ moved: moved.length,
1898
+ percent: Math.round((i + 1) / total * 100),
1899
+ currentFile: itemName
1900
+ });
1901
+ continue;
1902
+ }
1833
1903
  errors.push(`${itemName} not found`);
1834
1904
  sendEvent({
1835
1905
  type: "progress",