-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from professor-k/master
Unobtrusive backups using built in backup functionality build into bedrock-server. Replaces the old code that stopped, copied and restarted the server(s)
- Loading branch information
Showing
5 changed files
with
110 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
root = true | ||
|
||
[*.cs] | ||
indent_style = space | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace BedrockService | ||
{ | ||
internal class BackupFile | ||
{ | ||
public long Length { get; } | ||
|
||
public string Path { get; } | ||
|
||
private BackupFile(string path, long length) | ||
{ | ||
Path = path; | ||
Length = length; | ||
} | ||
|
||
public static bool IsBackupSpecification(string input) | ||
{ | ||
return input?.Contains(".ldb:") ?? false; | ||
} | ||
|
||
public static List<BackupFile> ParseBackupSpecification(string input) | ||
{ | ||
return input | ||
.Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries) | ||
.Select(ParseFileSpec) | ||
.ToList(); | ||
} | ||
|
||
private static BackupFile ParseFileSpec(string fileSpec) | ||
{ | ||
var chunks = fileSpec.Split(':'); | ||
|
||
// bedrock server returns paths with forward slashes, | ||
// but since we're on windows we need to convert them to backslashes | ||
var path = chunks[0].Replace('/', '\\'); | ||
return new BackupFile(path, long.Parse(chunks[1])); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters