@gallop.software/studio 2.1.15 → 2.1.16
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.
- package/dist/server/index.js +31 -108
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -1000,6 +1000,34 @@ async function deleteEmptyFolders(folderPath) {
|
|
|
1000
1000
|
} catch {
|
|
1001
1001
|
}
|
|
1002
1002
|
}
|
|
1003
|
+
async function cleanupEmptyFoldersRecursive(dir) {
|
|
1004
|
+
try {
|
|
1005
|
+
const entries = await fs5.readdir(dir, { withFileTypes: true });
|
|
1006
|
+
let isEmpty = true;
|
|
1007
|
+
for (const entry of entries) {
|
|
1008
|
+
if (entry.isDirectory()) {
|
|
1009
|
+
const subDirEmpty = await cleanupEmptyFoldersRecursive(path5.join(dir, entry.name));
|
|
1010
|
+
if (!subDirEmpty) isEmpty = false;
|
|
1011
|
+
} else if (!isHiddenOrSystemFile(entry.name)) {
|
|
1012
|
+
isEmpty = false;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
if (isEmpty) {
|
|
1016
|
+
for (const entry of entries) {
|
|
1017
|
+
if (!entry.isDirectory() && isHiddenOrSystemFile(entry.name)) {
|
|
1018
|
+
try {
|
|
1019
|
+
await fs5.unlink(path5.join(dir, entry.name));
|
|
1020
|
+
} catch {
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
await fs5.rmdir(dir);
|
|
1025
|
+
}
|
|
1026
|
+
return isEmpty;
|
|
1027
|
+
} catch {
|
|
1028
|
+
return true;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1003
1031
|
|
|
1004
1032
|
// src/handlers/files.ts
|
|
1005
1033
|
async function handleUpload(request) {
|
|
@@ -1599,13 +1627,6 @@ async function handleUnprocessStream(request) {
|
|
|
1599
1627
|
`));
|
|
1600
1628
|
};
|
|
1601
1629
|
try {
|
|
1602
|
-
let isHiddenOrSystemFile3 = function(filename) {
|
|
1603
|
-
if (filename.startsWith(".")) return true;
|
|
1604
|
-
const windowsFiles = ["thumbs.db", "desktop.ini", "ehthumbs.db", "ehthumbs_vista.db"];
|
|
1605
|
-
if (windowsFiles.includes(filename.toLowerCase())) return true;
|
|
1606
|
-
return false;
|
|
1607
|
-
};
|
|
1608
|
-
var isHiddenOrSystemFile2 = isHiddenOrSystemFile3;
|
|
1609
1630
|
const meta = await loadMeta();
|
|
1610
1631
|
const cdnUrls = getCdnUrls(meta);
|
|
1611
1632
|
const removed = [];
|
|
@@ -1665,37 +1686,9 @@ async function handleUnprocessStream(request) {
|
|
|
1665
1686
|
await purgeCloudflareCache(urlsToPurge);
|
|
1666
1687
|
}
|
|
1667
1688
|
sendEvent({ type: "cleanup", message: "Cleaning up empty folders..." });
|
|
1668
|
-
async function cleanEmptyFolders(dir) {
|
|
1669
|
-
try {
|
|
1670
|
-
const entries = await fs7.readdir(dir, { withFileTypes: true });
|
|
1671
|
-
let isEmpty = true;
|
|
1672
|
-
for (const entry of entries) {
|
|
1673
|
-
if (entry.isDirectory()) {
|
|
1674
|
-
const subDirEmpty = await cleanEmptyFolders(path7.join(dir, entry.name));
|
|
1675
|
-
if (!subDirEmpty) isEmpty = false;
|
|
1676
|
-
} else if (!isHiddenOrSystemFile3(entry.name)) {
|
|
1677
|
-
isEmpty = false;
|
|
1678
|
-
}
|
|
1679
|
-
}
|
|
1680
|
-
if (isEmpty) {
|
|
1681
|
-
for (const entry of entries) {
|
|
1682
|
-
if (!entry.isDirectory() && isHiddenOrSystemFile3(entry.name)) {
|
|
1683
|
-
try {
|
|
1684
|
-
await fs7.unlink(path7.join(dir, entry.name));
|
|
1685
|
-
} catch {
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
await fs7.rmdir(dir);
|
|
1690
|
-
}
|
|
1691
|
-
return isEmpty;
|
|
1692
|
-
} catch {
|
|
1693
|
-
return true;
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
1689
|
const imagesDir = getPublicPath("images");
|
|
1697
1690
|
try {
|
|
1698
|
-
await
|
|
1691
|
+
await cleanupEmptyFoldersRecursive(imagesDir);
|
|
1699
1692
|
} catch {
|
|
1700
1693
|
}
|
|
1701
1694
|
let message = `Removed thumbnails from ${removed.length} image${removed.length !== 1 ? "s" : ""}.`;
|
|
@@ -1978,13 +1971,6 @@ async function handleScanStream() {
|
|
|
1978
1971
|
`));
|
|
1979
1972
|
};
|
|
1980
1973
|
try {
|
|
1981
|
-
let isHiddenOrSystemFile3 = function(filename) {
|
|
1982
|
-
if (filename.startsWith(".")) return true;
|
|
1983
|
-
const windowsFiles = ["thumbs.db", "desktop.ini", "ehthumbs.db", "ehthumbs_vista.db"];
|
|
1984
|
-
if (windowsFiles.includes(filename.toLowerCase())) return true;
|
|
1985
|
-
return false;
|
|
1986
|
-
};
|
|
1987
|
-
var isHiddenOrSystemFile2 = isHiddenOrSystemFile3;
|
|
1988
1974
|
const meta = await loadMeta();
|
|
1989
1975
|
const existingCount = Object.keys(meta).filter((k) => !k.startsWith("_")).length;
|
|
1990
1976
|
const existingKeys = new Set(Object.keys(meta));
|
|
@@ -2130,36 +2116,8 @@ async function handleScanStream() {
|
|
|
2130
2116
|
}
|
|
2131
2117
|
}
|
|
2132
2118
|
await cleanEmptyFolders(getPublicPath());
|
|
2133
|
-
async function cleanImagesFolders(dir) {
|
|
2134
|
-
try {
|
|
2135
|
-
const entries = await fs8.readdir(dir, { withFileTypes: true });
|
|
2136
|
-
let isEmpty = true;
|
|
2137
|
-
for (const entry of entries) {
|
|
2138
|
-
if (entry.isDirectory()) {
|
|
2139
|
-
const subDirEmpty = await cleanImagesFolders(path8.join(dir, entry.name));
|
|
2140
|
-
if (!subDirEmpty) isEmpty = false;
|
|
2141
|
-
} else if (!isHiddenOrSystemFile3(entry.name)) {
|
|
2142
|
-
isEmpty = false;
|
|
2143
|
-
}
|
|
2144
|
-
}
|
|
2145
|
-
if (isEmpty) {
|
|
2146
|
-
for (const entry of entries) {
|
|
2147
|
-
if (!entry.isDirectory() && isHiddenOrSystemFile3(entry.name)) {
|
|
2148
|
-
try {
|
|
2149
|
-
await fs8.unlink(path8.join(dir, entry.name));
|
|
2150
|
-
} catch {
|
|
2151
|
-
}
|
|
2152
|
-
}
|
|
2153
|
-
}
|
|
2154
|
-
await fs8.rmdir(dir);
|
|
2155
|
-
}
|
|
2156
|
-
return isEmpty;
|
|
2157
|
-
} catch {
|
|
2158
|
-
return true;
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
2119
|
try {
|
|
2162
|
-
await
|
|
2120
|
+
await cleanupEmptyFoldersRecursive(imagesDir);
|
|
2163
2121
|
} catch {
|
|
2164
2122
|
}
|
|
2165
2123
|
await saveMeta(meta);
|
|
@@ -2190,13 +2148,6 @@ async function handleScanStream() {
|
|
|
2190
2148
|
}
|
|
2191
2149
|
async function handleDeleteOrphans(request) {
|
|
2192
2150
|
try {
|
|
2193
|
-
let isHiddenOrSystemFile3 = function(filename) {
|
|
2194
|
-
if (filename.startsWith(".")) return true;
|
|
2195
|
-
const windowsFiles = ["thumbs.db", "desktop.ini", "ehthumbs.db", "ehthumbs_vista.db"];
|
|
2196
|
-
if (windowsFiles.includes(filename.toLowerCase())) return true;
|
|
2197
|
-
return false;
|
|
2198
|
-
};
|
|
2199
|
-
var isHiddenOrSystemFile2 = isHiddenOrSystemFile3;
|
|
2200
2151
|
const { paths } = await request.json();
|
|
2201
2152
|
if (!paths || !Array.isArray(paths) || paths.length === 0) {
|
|
2202
2153
|
return jsonResponse({ error: "No paths provided" }, { status: 400 });
|
|
@@ -2218,36 +2169,8 @@ async function handleDeleteOrphans(request) {
|
|
|
2218
2169
|
}
|
|
2219
2170
|
}
|
|
2220
2171
|
const imagesDir = getPublicPath("images");
|
|
2221
|
-
async function removeEmptyDirs(dir) {
|
|
2222
|
-
try {
|
|
2223
|
-
const entries = await fs8.readdir(dir, { withFileTypes: true });
|
|
2224
|
-
let isEmpty = true;
|
|
2225
|
-
for (const entry of entries) {
|
|
2226
|
-
if (entry.isDirectory()) {
|
|
2227
|
-
const subDirEmpty = await removeEmptyDirs(path8.join(dir, entry.name));
|
|
2228
|
-
if (!subDirEmpty) isEmpty = false;
|
|
2229
|
-
} else if (!isHiddenOrSystemFile3(entry.name)) {
|
|
2230
|
-
isEmpty = false;
|
|
2231
|
-
}
|
|
2232
|
-
}
|
|
2233
|
-
if (isEmpty) {
|
|
2234
|
-
for (const entry of entries) {
|
|
2235
|
-
if (!entry.isDirectory() && isHiddenOrSystemFile3(entry.name)) {
|
|
2236
|
-
try {
|
|
2237
|
-
await fs8.unlink(path8.join(dir, entry.name));
|
|
2238
|
-
} catch {
|
|
2239
|
-
}
|
|
2240
|
-
}
|
|
2241
|
-
}
|
|
2242
|
-
await fs8.rmdir(dir);
|
|
2243
|
-
}
|
|
2244
|
-
return isEmpty;
|
|
2245
|
-
} catch {
|
|
2246
|
-
return true;
|
|
2247
|
-
}
|
|
2248
|
-
}
|
|
2249
2172
|
try {
|
|
2250
|
-
await
|
|
2173
|
+
await cleanupEmptyFoldersRecursive(imagesDir);
|
|
2251
2174
|
} catch {
|
|
2252
2175
|
}
|
|
2253
2176
|
return jsonResponse({
|