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

Don't leave lingering worldname/maps directories #25721

Merged
merged 1 commit into from
Sep 23, 2018

Conversation

mark7
Copy link
Contributor

@mark7 mark7 commented Sep 20, 2018

Summary

SUMMARY: Bugfixes "Don't leave lingering worldname/maps directories"

Purpose of change

At least on the Linux target, once a maps directory had been created
for a world, when the world was deleted, the world directory and maps
directory could be left behind. This was caused when Cataclysm
attempted to delete non-empty parent directories before child
directories, which silently failed.

Describe the solution

Iterate over directories being deleted during world deletion by
pathname length, so that children will always be deleted before parent
directories.

Describe alternatives you've considered

Additional context

void worldfactory::delete_world( const std::string &worldname, const bool delete_folder )
{
std::string worldpath = get_world( worldname )->folder_path();
std::set<std::string> directory_paths;
std::set<std::string, directory_pathname_length_sorter> directory_paths;
Copy link
Contributor

Choose a reason for hiding this comment

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

This will end up badly for different paths with the same length. I think you can just delete the directories using reverse iterator since the default sorter compares strings by lexicographical order. (Or alternatively, use std::greater as the sorter.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, gotcha, thanks. Didn't realize that the test was used for set uniqueness as well, but that does make a good deal more sense.

At least on the Linux target, once a maps directory had been created
for a world, when the world was deleted, the world directory and maps
directory could be left behind.  This was caused when Cataclysm
attempted to delete non-empty parent directories before child
directories, which silently failed.

Iterate over directories being deleted during world deletion in
reverse order, so that children will always be deleted before parent
directories.
@Leland
Copy link
Contributor

Leland commented Sep 20, 2018

Yay, I'd noticed this issue on macOS as well

@MT-Arnoldussen
Copy link
Contributor

can confirm it happened on Windows as well. hopefully this finally fixes it

@nexusmrsep nexusmrsep added the Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style label Sep 20, 2018
@ZhilkinSerg ZhilkinSerg self-assigned this Sep 23, 2018
@ZhilkinSerg ZhilkinSerg merged commit b3e604a into CleverRaven:master Sep 23, 2018
@ZhilkinSerg ZhilkinSerg removed their assignment Sep 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants