From d15355cc602618d1c7df384da2f2f30ccd76dfc3 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sat, 2 Mar 2013 10:50:47 -0800 Subject: [PATCH] Stop writing to data files before doing a backup --- minecraft/save_world.cgi | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/minecraft/save_world.cgi b/minecraft/save_world.cgi index 85f9e6039..15f061f9d 100755 --- a/minecraft/save_world.cgi +++ b/minecraft/save_world.cgi @@ -109,12 +109,24 @@ elsif ($in{'download'} && !$ENV{'PATH_INFO'}) { elsif ($in{'download'} && $ENV{'PATH_INFO'}) { # Download world as ZIP file $in{'name'} || &error("Missing world name"); + if (&is_minecraft_server_running() && + $def eq $in{'name'}) { + # Flush state to disk + &execute_minecraft_command("save-all"); + &execute_minecraft_command("save-off"); + } my $temp = &transname().".zip"; my $out = &backquote_command( "cd ".quotemeta($config{'minecraft_dir'})." && ". "zip -r $temp ".quotemeta($in{'name'})); + my $ex = $?; + if (&is_minecraft_server_running() && + $def eq $in{'name'}) { + # Re-enable world writes + &execute_minecraft_command("save-on"); + } my @st = stat($temp); - !$? && @st || + !$ex && @st || &error(&text('world_ezip', "".&html_escape($out)."")); print "Content-type: application/zip\n"; print "Content-length: $st[7]\n";