Skip to content

Commit

Permalink
Fix correctly exporting desktop icon when project is saved in the clo…
Browse files Browse the repository at this point in the history
…ud (#7282)
  • Loading branch information
ClementPasteau authored Jan 6, 2025
1 parent 5ab9c56 commit 3d80709
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
7 changes: 2 additions & 5 deletions GDJS/GDJS/IDE/Exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,8 @@ bool Exporter::ExportWholePixiProject(const ExportOptions &options) {
exportedProject, options.exportPath, usedExtensions))
return false;

if (!helper.ExportBuildResourcesElectronFiles(
// It's important to use the original project here, as the exported
// project can have its resources modified.
options.project,
options.exportPath))
if (!helper.ExportBuildResourcesElectronFiles(exportedProject,
options.exportPath))
return false;
} else if (options.target == "facebookInstantGames") {
if (!exportProject(options.exportPath)) return false;
Expand Down
4 changes: 1 addition & 3 deletions GDJS/GDJS/IDE/ExporterHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,7 @@ bool ExporterHelper::ExportBuildResourcesElectronFiles(
.GetResource(platformSpecificAssets.Get("desktop", "icon-512"))
.GetFile();

auto projectDirectory = gd::AbstractFileSystem::NormalizeSeparator(
fs.DirNameFrom(project.GetProjectFile()));
fs.MakeAbsolute(iconFilename, projectDirectory);
fs.MakeAbsolute(iconFilename, exportDir + "/app");
fs.MkDir(exportDir + "/buildResources");
if (fs.FileExists(iconFilename)) {
fs.CopyFile(iconFilename, exportDir + "/buildResources/icon.png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,21 @@ export default class BrowserFileSystem {
return true;
}

// If this is a file that we have to download,
// consider the file copied by getting it to be downloaded in the new destination
const existingDestToDownload = Object.keys(this._filesToDownload).find(
filePath => filePath === source
);
if (existingDestToDownload) {
const existingSourceToDownload = this._filesToDownload[
existingDestToDownload
];
this._filesToDownload[
pathPosix.normalize(dest)
] = existingSourceToDownload;
return true;
}

console.error(`File not found in copyFile (from ${source} to ${dest}).`);
return false;
};
Expand Down
17 changes: 17 additions & 0 deletions newIDE/app/src/ExportAndShare/LocalExporters/LocalFileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,23 @@ class LocalFileSystem {
try {
if (source !== dest) fs.copySync(source, dest);
} catch (e) {
if (e.code === 'ENOENT') {
// If the file does not exist, it's possible it is meant to be downloaded.
// In this case, consider the file copied by getting it to be downloaded in the new destination.
const existingDestToDownload = Object.keys(this._filesToDownload).find(
filePath => filePath === source
);
if (existingDestToDownload) {
const existingSourceToDownload = this._filesToDownload[
existingDestToDownload
];
this._filesToDownload[
pathPosix.normalize(dest)
] = existingSourceToDownload;
return true;
}
}

console.error('copyFile(' + source + ', ' + dest + ') failed: ' + e);
return false;
}
Expand Down

0 comments on commit 3d80709

Please sign in to comment.