Skip to content

Commit 0771088

Browse files
committed
Fix endless reloads of in-game editor on Windows due to autosave
Also fix ignored files watching on Windows
1 parent a4c6228 commit 0771088

File tree

6 files changed

+39
-16
lines changed

6 files changed

+39
-16
lines changed

newIDE/app/src/ExportAndShare/BrowserExporters/BrowserS3PreviewLauncher/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ export default class BrowserS3PreviewLauncher extends React.Component<
194194
previewOptions.authenticatedPlayer.playerToken
195195
);
196196
}
197-
if (previewOptions.captureOptions.screenshots) {
197+
if (
198+
previewOptions.captureOptions &&
199+
previewOptions.captureOptions.screenshots
200+
) {
198201
previewOptions.captureOptions.screenshots.forEach(screenshot => {
199202
previewExportOptions.addScreenshotCapture(
200203
screenshot.delayTimeInSeconds,

newIDE/app/src/ExportAndShare/BrowserExporters/BrowserSWPreviewLauncher/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,10 @@ export default class BrowserSWPreviewLauncher extends React.Component<
232232
previewOptions.authenticatedPlayer.playerToken
233233
);
234234
}
235-
if (previewOptions.captureOptions.screenshots) {
235+
if (
236+
previewOptions.captureOptions &&
237+
previewOptions.captureOptions.screenshots
238+
) {
236239
previewOptions.captureOptions.screenshots.forEach(screenshot => {
237240
previewExportOptions.addScreenshotCapture(
238241
screenshot.delayTimeInSeconds,

newIDE/app/src/ExportAndShare/PreviewLauncher.flow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export type PreviewOptions = {|
6363
editorId: string,
6464
getIsMenuBarHiddenInPreview: () => boolean,
6565
getIsAlwaysOnTopInPreview: () => boolean,
66-
captureOptions: CaptureOptions,
66+
captureOptions: CaptureOptions | null,
6767
onCaptureFinished: CaptureOptions => Promise<void>,
6868
inAppTutorialMessageInPreview: string,
6969
inAppTutorialMessagePositionInPreview: string,

newIDE/app/src/MainFrame/index.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,9 +2182,11 @@ const MainFrame = (props: Props) => {
21822182
? previewState.overridenPreviewExternalLayoutName
21832183
: previewState.previewExternalLayoutName;
21842184

2185-
autosaveProjectIfNeeded().catch(err => {
2186-
console.error('Error while auto-saving the project. Ignoring.', err);
2187-
});
2185+
if (!isForInGameEdition) {
2186+
autosaveProjectIfNeeded().catch(err => {
2187+
console.error('Error while auto-saving the project. Ignoring.', err);
2188+
});
2189+
}
21882190

21892191
// Note that in the future, this kind of checks could be done
21902192
// and stored in a "diagnostic report", rather than hiding errors
@@ -2198,11 +2200,12 @@ const MainFrame = (props: Props) => {
21982200
}
21992201
: null;
22002202

2201-
const authenticatedPlayer = await getAuthenticatedPlayerForPreview();
2202-
2203-
const captureOptions = await createCaptureOptionsForPreview(
2204-
launchCaptureOptions
2205-
);
2203+
const [authenticatedPlayer, captureOptions] = await Promise.all([
2204+
isForInGameEdition ? null : getAuthenticatedPlayerForPreview(),
2205+
isForInGameEdition
2206+
? null
2207+
: createCaptureOptionsForPreview(launchCaptureOptions),
2208+
]);
22062209

22072210
try {
22082211
await eventsFunctionsExtensionsState.ensureLoadFinished();

newIDE/app/src/ProjectsStorage/LocalFileStorageProvider/LocalFileResourcesWatcher.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ export const setupResourcesWatcher =
4848
// never ending.
4949
debouncedCallback(path);
5050
});
51+
52+
// Note: this ignore list is not a list of glob. Any file that matches a string in this list will be ignored.
53+
// This could be improved to separate this in a list of paths, filenames, etc.
5154
const ignore = [
5255
path.sep + '.DS_Store', // macOS folder attributes file
5356
path.sep + '.git', // For projects using git as a versioning tool.
@@ -58,7 +61,7 @@ export const setupResourcesWatcher =
5861
if (options && options.isProjectSplitInMultipleFiles) {
5962
ignore.push(
6063
...splittedProjectFolderNames.map(folderName =>
61-
path.join(folderPath, folderName, '*.json')
64+
path.join(folderPath, folderName)
6265
)
6366
);
6467
}

newIDE/electron-app/app/LocalFilesystemWatcher.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,35 @@ const getNewSubscriptionId = () => {
1010
return id.toString();
1111
};
1212

13+
const normalizePath = path => {
14+
if (!path) return ''; // Safety check
15+
16+
return path.replace(/\\/g, '/');
17+
};
18+
1319
const setupWatcher = (folderPath, fileWiseCallback, serializedOptions) => {
1420
const options = JSON.parse(serializedOptions);
1521
const newSubscriptionId = getNewSubscriptionId();
1622
const watcher = fileWatcher
1723
.watch(folderPath, {
1824
ignored: candidatePath => {
25+
// Normalize the path to avoid issues with different path separators (\ on Windows, / on other OSes).
26+
// Even on Windows, "candidatePath" returned by chokidar is always using "/".
27+
// So we normalize all paths (candidatePath and ignore paths) to avoid missing ignored files on Windows.
28+
const normalizedCandidatePath = normalizePath(candidatePath);
29+
1930
if (
2031
(options.ignore || []).some(ignore =>
21-
candidatePath.includes(ignore)
32+
normalizedCandidatePath.includes(normalizePath(ignore))
2233
) ||
2334
// Force ignore, for safety, any node_modules folder as they are too big and would crash the watcher on macOS.
2435
// Note that this will ignore any folder whose name is prefixed by "node_modules".
25-
candidatePath.includes(path.sep + 'node_modules') ||
36+
normalizedCandidatePath.includes('/node_modules') ||
2637
// Same for git repositories (and any file starting by ".git").
27-
candidatePath.includes(path.sep + '.git')
38+
normalizedCandidatePath.includes('/.git')
2839
) {
2940
console.info(
30-
`Local file watcher has ignored path "${candidatePath}".`
41+
`Local file watcher has ignored path "${normalizedCandidatePath}".`
3142
);
3243
return true;
3344
}

0 commit comments

Comments
 (0)