Skip to content

Commit 25a36d8

Browse files
committed
fix: site variables
1 parent b5e43a8 commit 25a36d8

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

templates/cli/lib/commands/push.js.twig

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ const awaitPools = {
152152
iteration + 1
153153
);
154154
},
155-
wipeVariables: async (functionId, iteration = 1) => {
155+
wipeFunctionVariables: async (functionId, iteration = 1) => {
156156
if (iteration > pollMaxDebounces) {
157157
return false;
158158
}
@@ -178,11 +178,42 @@ const awaitPools = {
178178

179179
await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
180180

181-
return await awaitPools.wipeVariables(
181+
return await awaitPools.wipeFunctionVariables(
182182
functionId,
183183
iteration + 1
184184
);
185185
},
186+
wipeSiteVariables: async (siteId, iteration = 1) => {
187+
if (iteration > pollMaxDebounces) {
188+
return false;
189+
}
190+
191+
const { total } = await sitesListVariables({
192+
siteId,
193+
queries: ['limit(1)'],
194+
parseOutput: false
195+
});
196+
197+
if (total === 0) {
198+
return true;
199+
}
200+
201+
if (pollMaxDebounces === POLL_DEFAULT_VALUE) {
202+
let steps = Math.max(1, Math.ceil(total / STEP_SIZE));
203+
if (steps > 1 && iteration === 1) {
204+
pollMaxDebounces *= steps;
205+
206+
log('Found a large number of variables, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
207+
}
208+
}
209+
210+
await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
211+
212+
return await awaitPools.wipeSiteVariables(
213+
siteId,
214+
iteration + 1
215+
);
216+
},
186217
deleteAttributes: async (databaseId, collectionId, attributeKeys, iteration = 1) => {
187218
if (iteration > pollMaxDebounces) {
188219
return false;
@@ -1231,7 +1262,7 @@ const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero:
12311262
});
12321263
}));
12331264

1234-
let result = await awaitPools.wipeVariables(site['$id']);
1265+
let result = await awaitPools.wipeSiteVariables(site['$id']);
12351266
if (!result) {
12361267
updaterRow.fail({ errorMessage: `Variable deletion timed out.` })
12371268
return;
@@ -1253,7 +1284,8 @@ const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero:
12531284
siteId: site['$id'],
12541285
key: variable.key,
12551286
value: variable.value,
1256-
parseOutput: false
1287+
parseOutput: false,
1288+
secret: false
12571289
});
12581290
}));
12591291
}
@@ -1557,7 +1589,7 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur
15571589
});
15581590
}));
15591591

1560-
let result = await awaitPools.wipeVariables(func['$id']);
1592+
let result = await awaitPools.wipeFunctionVariables(func['$id']);
15611593
if (!result) {
15621594
updaterRow.fail({ errorMessage: `Variable deletion timed out.` })
15631595
return;

0 commit comments

Comments
 (0)