summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2014-01-25 15:33:33 +0100
committersnowleo <schneeleo@gmail.com>2014-01-25 15:33:33 +0100
commitb6a550fdcb113ce40fca760dd9b963a4606e8d1e (patch)
tree21f20f1d48c3ea1b42483c0ee7af4c27628a7f55
parentba6b83140f668a40d6d3b20f4ea98b2ccb5599c0 (diff)
downloadEssentials-b6a550fdcb113ce40fca760dd9b963a4606e8d1e.tar
Essentials-b6a550fdcb113ce40fca760dd9b963a4606e8d1e.tar.gz
Essentials-b6a550fdcb113ce40fca760dd9b963a4606e8d1e.tar.lz
Essentials-b6a550fdcb113ce40fca760dd9b963a4606e8d1e.tar.xz
Essentials-b6a550fdcb113ce40fca760dd9b963a4606e8d1e.zip
Read backup output async
-rw-r--r--Essentials/src/com/earth2me/essentials/Backup.java102
1 files changed, 57 insertions, 45 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Backup.java b/Essentials/src/com/earth2me/essentials/Backup.java
index 2e754d0f2..3c6621864 100644
--- a/Essentials/src/com/earth2me/essentials/Backup.java
+++ b/Essentials/src/com/earth2me/essentials/Backup.java
@@ -91,65 +91,77 @@ public class Backup implements Runnable
server.dispatchCommand(cs, "save-all");
server.dispatchCommand(cs, "save-off");
- ess.runTaskAsynchronously(
- new Runnable()
+ ess.runTaskAsynchronously(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ try
{
- @Override
- public void run()
+ final ProcessBuilder childBuilder = new ProcessBuilder(command);
+ childBuilder.redirectErrorStream(true);
+ childBuilder.directory(ess.getDataFolder().getParentFile().getParentFile());
+ final Process child = childBuilder.start();
+ ess.runTaskAsynchronously(new Runnable()
{
- try
+ @Override
+ public void run()
{
- final ProcessBuilder childBuilder = new ProcessBuilder(command);
- childBuilder.redirectErrorStream(true);
- childBuilder.directory(ess.getDataFolder().getParentFile().getParentFile());
- final Process child = childBuilder.start();
- final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()));
try
{
- child.waitFor();
- String line;
- do
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()));
+ try
{
- line = reader.readLine();
- if (line != null)
+ String line;
+ do
{
- LOGGER.log(Level.INFO, line);
+ line = reader.readLine();
+ if (line != null)
+ {
+ LOGGER.log(Level.INFO, line);
+ }
}
+ while (line != null);
+ }
+ finally
+ {
+ reader.close();
}
- while (line != null);
}
- finally
+ catch (IOException ex)
{
- reader.close();
+ LOGGER.log(Level.SEVERE, null, ex);
}
}
- catch (InterruptedException ex)
- {
- LOGGER.log(Level.SEVERE, null, ex);
- }
- catch (IOException ex)
- {
- LOGGER.log(Level.SEVERE, null, ex);
- }
- finally
+ });
+ child.waitFor();
+ }
+ catch (InterruptedException ex)
+ {
+ LOGGER.log(Level.SEVERE, null, ex);
+ }
+ catch (IOException ex)
+ {
+ LOGGER.log(Level.SEVERE, null, ex);
+ }
+ finally
+ {
+ ess.scheduleSyncDelayedTask(new Runnable()
+ {
+ @Override
+ public void run()
{
- ess.scheduleSyncDelayedTask(
- new Runnable()
- {
- @Override
- public void run()
- {
- server.dispatchCommand(cs, "save-on");
- if (server.getOnlinePlayers().length == 0)
- {
- stopTask();
- }
- active = false;
- LOGGER.log(Level.INFO, _("backupFinished"));
- }
- });
+ server.dispatchCommand(cs, "save-on");
+ if (server.getOnlinePlayers().length == 0)
+ {
+ stopTask();
+ }
+ active = false;
+ LOGGER.log(Level.INFO, _("backupFinished"));
}
- }
- });
+ });
+ }
+ }
+ });
}
}