Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore __MACOSX directory for export template and project ZIPs #99947

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion editor/export/export_template_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,13 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_
}

String file = String::utf8(fname);

// Skip the __MACOSX directory created by macOS's built-in file zipper.
if (file.begins_with("__MACOSX")) {
ret = unzGoToNextFile(pkg);
continue;
}

if (file.ends_with("version.txt")) {
Vector<uint8_t> uncomp_data;
uncomp_data.resize(info.uncompressed_size);
Expand Down Expand Up @@ -512,7 +519,8 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_

String file = file_path.get_file();

if (file.size() == 0) {
// Skip the __MACOSX directory created by macOS's built-in file zipper.
if (file.is_empty() || file.begins_with("__MACOSX")) {
ret = unzGoToNextFile(pkg);
continue;
}
Expand Down
24 changes: 23 additions & 1 deletion editor/project_manager/project_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ void ProjectDialog::_validate_path() {
ERR_FAIL_COND_MSG(ret != UNZ_OK, "Failed to get current file info.");

String name = String::utf8(fname);

// Skip the __MACOSX directory created by macOS's built-in file zipper.
if (name.begins_with("__MACOSX")) {
ret = unzGoToNextFile(pkg);
continue;
}

if (name.get_file() == "project.godot") {
break; // ret == UNZ_OK.
}
Expand Down Expand Up @@ -604,6 +611,13 @@ void ProjectDialog::ok_pressed() {
ERR_FAIL_COND_MSG(ret != UNZ_OK, "Failed to get current file info.");

String name = String::utf8(fname);

// Skip the __MACOSX directory created by macOS's built-in file zipper.
if (name.begins_with("__MACOSX")) {
ret = unzGoToNextFile(pkg);
continue;
}

if (name.get_file() == "project.godot") {
zip_root = name.get_base_dir();
break;
Expand Down Expand Up @@ -636,7 +650,15 @@ void ProjectDialog::ok_pressed() {
ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0);
ERR_FAIL_COND_MSG(ret != UNZ_OK, "Failed to get current file info.");

String rel_path = String::utf8(fname).trim_prefix(zip_root);
String name = String::utf8(fname);

// Skip the __MACOSX directory created by macOS's built-in file zipper.
if (name.begins_with("__MACOSX")) {
ret = unzGoToNextFile(pkg);
continue;
}

String rel_path = name.trim_prefix(zip_root);
if (rel_path.is_empty()) { // Root.
} else if (rel_path.ends_with("/")) { // Directory.
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
Expand Down