@gallop.software/studio 2.3.39 → 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.
@@ -1829,9 +1829,77 @@ async function handleMoveStream(request) {
1829
1829
  });
1830
1830
  continue;
1831
1831
  }
1832
+ let hasLocalItem = false;
1832
1833
  try {
1833
1834
  await fs6.access(absolutePath);
1835
+ hasLocalItem = true;
1834
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
+ }
1835
1903
  errors.push(`${itemName} not found`);
1836
1904
  sendEvent({
1837
1905
  type: "progress",