Skip to content

Commit

Permalink
Add: remove backup command
Browse files Browse the repository at this point in the history
  • Loading branch information
hhhxiao committed Apr 16, 2022
1 parent cd9a91d commit 42ca95f
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions mod/function/BackupHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace mod {
namespace {

bool isValidWorldFolder(const std::filesystem::path &path) {
// TODO check if is a valid mineraft bedrock level
// TODO check if is a valid minecraft bedrock level
return true;
}

Expand Down Expand Up @@ -56,8 +56,9 @@ Copy-Item -Path $SourcePath -Destination "$Destination" -Recurse | Out-Null
if (entry.status().type() == fs::file_type::directory) {
for (const auto &iter :
fs::directory_iterator(backupRootPath)) {
if (fs::is_directory(iter.path()) &&
isValidWorldFolder(iter.path())) {
if (fs::is_directory(iter.path())
// && isValidWorldFolder(iter.path())
) {
auto str = iter.path().string();
auto p1 = str.rfind('\\');
backupList.push_back(
Expand Down Expand Up @@ -116,10 +117,15 @@ Copy-Item -Path $SourcePath -Destination "$Destination" -Recurse | Out-Null
"./plugins/trapdoor/backup/" + target_backup_to_remove;
// TODO: add remove to thread pool.
trapdoor::info(player, "Remove path is [%s]", remove_path.c_str());
std::error_code ec;
fs::remove_all(remove_path, ec);
L_DEBUG("INfo is %s", ec.message().c_str());
try {
fs::remove_all(remove_path);
trapdoor::info(player, "Success");
} catch (std::exception &e) {
trapdoor::info(player, "Error remove backup with reason %s ",
e.what());
}
}

} // namespace

void initBackup() {
Expand All @@ -142,7 +148,7 @@ Copy-Item -Path $SourcePath -Destination "$Destination" -Recurse | Out-Null
->then(ARG("crash", "command.backup.crash.desc", NONE, {
//这种指令的存在真的好吗
// trapdoor::warning(player, "this command has been removed");
*((char *)(0)) = 0;
abort();
}));
}

Expand Down

0 comments on commit 42ca95f

Please sign in to comment.