Skip to content

Fix #3218: 修复复制游戏版本里的“复制存档”选项失效问题#3868

Merged
Glavo merged 1 commit into
HMCL-dev:mainfrom
e74yp8:fix-duplicate-saves
May 12, 2025
Merged

Fix #3218: 修复复制游戏版本里的“复制存档”选项失效问题#3868
Glavo merged 1 commit into
HMCL-dev:mainfrom
e74yp8:fix-duplicate-saves

Conversation

@e74yp8

@e74yp8 e74yp8 commented Apr 28, 2025

Copy link
Copy Markdown
Contributor

Fix #3218

在复制version文件夹前补上了黑名单筛选的操作
以确保在选项开启后,存档文件夹不会被复制到新游戏版本

@e74yp8

e74yp8 commented Apr 28, 2025

Copy link
Copy Markdown
Contributor Author

跟PR #3843 是一样的更改,
抱歉刚才把PR误关了

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes issue #3218 by ensuring the "复制存档" option works as intended during version duplication. It adds blacklist filtering for specific files and folders (like saves), changes file operations for .jar and .json files from move to copy, and removes a redundant blacklist initialization block.

if (Files.exists(dstDir)) throw new IOException("Version exists");
FileUtils.copyDirectory(srcDir, dstDir);
FileUtils.copyDirectory(srcDir, dstDir, path -> Modpack.acceptFile(path, blackList, null));

Copilot AI May 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding a comment explaining why the source files (.jar, .json) are now resolved from srcDir instead of dstDir after copying the directory.

Suggested change
// Resolve the .json and .jar files from srcDir instead of dstDir to ensure they are explicitly copied
// and updated correctly, as FileUtils.copyDirectory may not handle these files in the same way.

Copilot uses AI. Check for mistakes.
Comment on lines 166 to 169

if (Files.exists(fromJar)) {
Files.move(fromJar, toJar);
Files.copy(fromJar, toJar);
}

Copilot AI May 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding a clarifying comment on the decision to use Files.copy instead of Files.move for the .jar and .json files, confirming that preserving the originals is intentional.

Copilot uses AI. Check for mistakes.
@Glavo Glavo merged commit b69602b into HMCL-dev:main May 12, 2025
2 checks passed
@e74yp8 e74yp8 deleted the fix-duplicate-saves branch May 13, 2025 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 复制游戏实例总会复制存档

3 participants