Table of Contents

Class ServerBackupsViewModel

Namespace
McServerLauncher.ViewModels
Assembly
McServerLauncher.dll

Manages world backups for a server: lists existing zip snapshots, and lets the user trigger one manually, restore an earlier one, or delete one. Automatic backups (before every start, after an explicit stop) are triggered by ServerViewModel itself; this view model is just the UI surface over the same WorldBackupService.

public class ServerBackupsViewModel : ObservableObject, INotifyPropertyChanged, INotifyPropertyChanging
Inheritance
ServerBackupsViewModel
Implements
Inherited Members

Remarks

The list is two piles, not one, and it says so. Retention counts the automatic backups (start, stop, while playing) together against one limit and the user's own (manual, before a restore) against another — WorldBackupService explains why. A flat list of five read as "five of each kind" with some missing, when it was the automatic pile, full. So the summary shows each pile against its limit, and the row the next backup of its pile will push out says so.

Grouped by day, and named by time and reason rather than by file: the zip's name is the same facts written for a file system, and it is still there as the row's tooltip.

Constructors

ServerBackupsViewModel(ServerViewModel)

public ServerBackupsViewModel(ServerViewModel server)

Parameters

server ServerViewModel

Properties

AutomaticCount

public int AutomaticCount { get; }

Property Value

int

AutomaticCountText

public string AutomaticCountText { get; }

Property Value

string

AutomaticFill

How full each pile is, 0–100, for the bar under its count.

public double AutomaticFill { get; }

Property Value

double

BackupNowCommand

Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.ServerBackupsViewModel.BackupNow().

[ExcludeFromCodeCoverage]
public IAsyncRelayCommand BackupNowCommand { get; }

Property Value

IAsyncRelayCommand

CanBackupNow

A backup can be made at any time now, running or not.

public bool CanBackupNow { get; }

Property Value

bool

Remarks

It used to need the server stopped, because zipping a world the JVM is writing to gives a torn copy. That is still true; what changed is that the server is now asked to let go of the world first — see LiveWorldBackup.

CanRestore

Restoring still needs the server stopped, and always will.

public bool CanRestore { get; }

Property Value

bool

Remarks

It deletes the world folder and unpacks another one in its place. There is no asking Minecraft to tolerate that. Nor while a start is getting ready: it would open whatever the restore had left half done. (Changes to that arrive with IsRunning, which NotifyCommandStates raises for both.)

Config

public ServerConfig Config { get; }

Property Value

ServerConfig

DeleteCommand

[ExcludeFromCodeCoverage]
public IAsyncRelayCommand<BackupItemViewModel?> DeleteCommand { get; }

Property Value

IAsyncRelayCommand<BackupItemViewModel>

Filter

[ExcludeFromCodeCoverage]
public BackupFilter Filter { get; set; }

Property Value

BackupFilter

Groups

The backups the filter lets through, by day, newest first.

public ObservableCollection<BackupDayGroup> Groups { get; }

Property Value

ObservableCollection<BackupDayGroup>

IsAllFilter

public bool IsAllFilter { get; }

Property Value

bool

IsAutomaticFilter

public bool IsAutomaticFilter { get; }

Property Value

bool

IsBusy

[ExcludeFromCodeCoverage]
public bool IsBusy { get; set; }

Property Value

bool

IsEmpty

public bool IsEmpty { get; }

Property Value

bool

IsFilterEmpty

There are backups, and none of the kind the filter asks for.

public bool IsFilterEmpty { get; }

Property Value

bool

IsManualFilter

public bool IsManualFilter { get; }

Property Value

bool

Items

Every backup, newest first, whatever the filter.

public ObservableCollection<BackupItemViewModel> Items { get; }

Property Value

ObservableCollection<BackupItemViewModel>

ManualCount

public int ManualCount { get; }

Property Value

int

ManualCountText

public string ManualCountText { get; }

Property Value

string

ManualFill

public double ManualFill { get; }

Property Value

double

NextBackupText

public string NextBackupText { get; }

Property Value

string

RefreshCommand

Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.ServerBackupsViewModel.Refresh().

[ExcludeFromCodeCoverage]
public IRelayCommand RefreshCommand { get; }

Property Value

IRelayCommand

RestoreCommand

[ExcludeFromCodeCoverage]
public IAsyncRelayCommand<BackupItemViewModel?> RestoreCommand { get; }

Property Value

IAsyncRelayCommand<BackupItemViewModel>

ShowAllCommand

Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.ServerBackupsViewModel.ShowAll().

[ExcludeFromCodeCoverage]
public IRelayCommand ShowAllCommand { get; }

Property Value

IRelayCommand

ShowAutomaticCommand

Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.ServerBackupsViewModel.ShowAutomatic().

[ExcludeFromCodeCoverage]
public IRelayCommand ShowAutomaticCommand { get; }

Property Value

IRelayCommand

ShowManualCommand

Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.ServerBackupsViewModel.ShowManual().

[ExcludeFromCodeCoverage]
public IRelayCommand ShowManualCommand { get; }

Property Value

IRelayCommand

StatusText

[ExcludeFromCodeCoverage]
public string StatusText { get; set; }

Property Value

string

TotalSizeText

public string TotalSizeText { get; }

Property Value

string

Methods

EnsureLoaded()

Loads the backup list the first time the tab is shown.

public void EnsureLoaded()

RefreshIfLoaded()

Re-reads the list, but only when there is one on screen to be wrong.

public void RefreshIfLoaded()

Remarks

The server's folder can be changed from its settings, which leaves this tab listing the snapshots of a different server. Loading it here instead would defeat EnsureLoaded(): the list is deliberately not read until somebody opens the tab.