Skip to content

Commit

Permalink
# 2024.07.16
Browse files Browse the repository at this point in the history
  • Loading branch information
drweb86 committed Jul 16, 2024
1 parent 786784f commit 0634b52
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 36 deletions.
2 changes: 1 addition & 1 deletion help/Version History (Changelog).md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 2024.07.13
# 2024.07.16

## Changes

Expand Down
1 change: 1 addition & 0 deletions sources/BUtil Tool.sln
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
RESX_ShowErrorsInErrorList = False
SolutionGuid = {A59777E8-22D7-4180-A61E-1EA0D374BAD6}
EndGlobalSection
EndGlobal
1 change: 0 additions & 1 deletion sources/BUtil.Linux/Services/LinuxAptGetArchiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ private static bool Extract(
throw new InvalidDataException("7-zip was not found. Use installation script.'");

var passwordIsSet = !string.IsNullOrWhiteSpace(password);
string input;
string arguments;
if (!passwordIsSet)
{
Expand Down
9 changes: 1 addition & 8 deletions sources/BUtil.Linux/Services/LinuxSupportManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,10 @@ public void OpenLatestRelease()

public string ScriptEngineName => "Bash";

public bool LaunchScript(ILog log, string script, string forbiddenForLogs)
public bool LaunchScript(ILog log, string script, string _)
{
// hack
forbiddenForLogs = null;

script = script.Replace("\r", string.Empty);

// hack.
if (forbiddenForLogs != null)
log.WriteLine(LoggingEvent.Debug, "Run script\n" + script.Replace(forbiddenForLogs, "***"));

using var tempDir = new TempFolder();
var scriptFile = Path.Combine(tempDir.Folder, "script.sh");
File.WriteAllText(scriptFile, "#!/bin/bash" + Environment.NewLine + script);
Expand Down
1 change: 0 additions & 1 deletion sources/BUtil.Windows/Services/SevenZipArchiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ private static bool Extract(
throw new InvalidDataException("7-zip was not found.");

var passwordIsSet = !string.IsNullOrWhiteSpace(password);
string input; // to handle wrong password
string arguments;
if (!passwordIsSet)
{
Expand Down
2 changes: 1 addition & 1 deletion sources/butil-ui.Desktop/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"butil-ui.Desktop": {
"commandName": "Project",
"commandLineArgs": "LaunchTask \"Task=Incremental\""
"commandLineArgs": "!LaunchTask \"Task=Incremental\""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class VersionsListView : UserControl
public VersionsListView()
{
InitializeComponent();
DataContext = new VersionsListViewModel(null);
DataContext = new VersionsListViewModel(null!);
}

public void BrowseFoldersCommand(object? sender, RoutedEventArgs args)
Expand Down
30 changes: 18 additions & 12 deletions sources/butil-ui/Controls/VersionsList/VersionsListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ public ObservableCollection<FileTreeNode> Nodes

public SolidColorBrush HeaderBackground { get; } = ColorPalette.GetBrush(SemanticColor.HeaderBackground);

private IncrementalBackupState _state;
private IStorageSettingsV2 _storageOptions;
private string _password;
private IncrementalBackupState? _state;
private IStorageSettingsV2? _storageOptions;
private string _password = string.Empty;
private static readonly char[] _separators = ['\\', '/'];

public void Initialize(IncrementalBackupState state, IStorageSettingsV2 storageOptions, string password)
Expand Down Expand Up @@ -301,16 +301,16 @@ public void Initialize(IncrementalBackupState state, IStorageSettingsV2 storageO
private void OnVersionChanged()
{
var version = SelectedVersion;
if (version == null)
if (version == null || _state == null)
return;

IsDeleteBackupVersionEnabled = version != null && Versions != null && Versions[0] != version;
IsDeleteBackupVersionEnabled = Versions != null && Versions[0] != version;

SelectedFileIsVisible = false;
var changes = GetChangesViewItems(version.Version);
var treeViewFiles = GetTreeViewFiles(_state, version.Version);
RefreshChanges(changes);
RefreshTreeView(treeViewFiles);
SelectedFileIsVisible = false;
var changes = GetChangesViewItems(version.Version);
var treeViewFiles = GetTreeViewFiles(_state, version.Version);
RefreshChanges(changes);
RefreshTreeView(treeViewFiles);
}

private void RefreshChanges(IEnumerable<Tuple<ChangeState, string>> changes)
Expand Down Expand Up @@ -442,6 +442,12 @@ private static void AddAsLeaves(FileTreeNode sourceItemNode, SourceItemV2 source
public async Task DeleteBackupVersionCommand()
{
var versionToDelete = SelectedVersion;
if (_state == null ||
_storageOptions == null)
{
return;
}

var closestFreshVersion = Versions[Versions.IndexOf(versionToDelete) - 1];
if (!await Messages.ShowYesNoDialog(string.Format(Resources.BackupVersion_Delete_Confirm, versionToDelete.Title, closestFreshVersion.Title)))
{
Expand Down Expand Up @@ -483,7 +489,7 @@ public void RecoverTo(string destinationFolder)
ParentViewModel.TaskExecuterViewModel = new TaskExecuterViewModel(
new TaskEvents(),
Resources.Task_Restore,
(log, taskEvents, onGetLastMinuteMessage) => new WriteStorageFilesToSourceFileRootTask(log, taskEvents, _storageOptions, SelectedNode.SourceItem, storageFiles, destinationFolder, onGetLastMinuteMessage),
(log, taskEvents, onGetLastMinuteMessage) => new WriteStorageFilesToSourceFileRootTask(log, taskEvents, _storageOptions!, SelectedNode.SourceItem, storageFiles, destinationFolder, onGetLastMinuteMessage),
isOk =>
{
if (isOk)
Expand All @@ -505,7 +511,7 @@ public void InitBlameForSelectedFile()
var items = new ObservableCollection<BlameViewItem>();
var path = SelectedNode?.StorageFile?.FileState.FileName ?? throw new NullReferenceException();

var descendingVersions = _state.VersionStates
var descendingVersions = _state!.VersionStates
.OrderByDescending(x => x.BackupDateUtc)
.ToList();

Expand Down
15 changes: 9 additions & 6 deletions sources/butil-ui/Controls/WhereTask/WhereTaskViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public void UpdateListMtpDevices()

public async Task MountTaskLaunchCommand()
{
if (string.IsNullOrWhiteSpace(FolderConnectionScript))
return;

var memoryLog = new MemoryLog();
if (PlatformSpecificExperience.Instance.SupportManager.LaunchScript(memoryLog, this.FolderConnectionScript, "***"))
await Messages.ShowInformationBox(Resources.DataStorage_Field_DisconnectionScript_Ok);
Expand Down Expand Up @@ -127,12 +130,12 @@ public IStorageSettingsV2 GetStorageSettings()
{
SingleBackupQuotaGb = Quota,

Host = FtpsServer,
Host = FtpsServer!,
Encryption = FtpsEncryption == Ftps_Encryption_Option_Explicit ?
FtpsStorageEncryptionV2.Explicit : FtpsStorageEncryptionV2.Implicit,
Port = FtpsPort,
User = FtpsUser,
Password = FtpsPassword,
User = FtpsUser!,
Password = FtpsPassword!,
Folder = FtpsFolder,
};
}
Expand All @@ -141,7 +144,7 @@ public IStorageSettingsV2 GetStorageSettings()
return new SambaStorageSettingsV2
{
SingleBackupQuotaGb = Quota,
Url = SmbUrl,
Url = SmbUrl!,
User = SmbUser,
Password = SmbPassword,
};
Expand All @@ -151,8 +154,8 @@ public IStorageSettingsV2 GetStorageSettings()
return new MtpStorageSettings
{
SingleBackupQuotaGb = Quota,
Device = MtpDevice,
Folder = MtpFolder
Device = MtpDevice!,
Folder = MtpFolder!
};
}
throw new System.ArgumentOutOfRangeException();
Expand Down
6 changes: 2 additions & 4 deletions sources/butil-ui/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public partial class MainWindowViewModel : ViewModelBase
public void GoDarkSide()
#pragma warning restore CA1822 // Mark members as static
{
new SettingsStoreService()
.Save(ThemeSetting.Name, ThemeSetting.DarkValue);
SettingsStoreService.Save(ThemeSetting.Name, ThemeSetting.DarkValue);
PlatformSpecificExperience.Instance
.SupportManager
.LaunchTasksApp();
Expand All @@ -38,8 +37,7 @@ public void GoDarkSide()
public void GoLightSide()
#pragma warning restore CA1822 // Mark members as static
{
new SettingsStoreService()
.Save(ThemeSetting.Name, ThemeSetting.LightValue);
SettingsStoreService.Save(ThemeSetting.Name, ThemeSetting.LightValue);
PlatformSpecificExperience.Instance
.SupportManager
.LaunchTasksApp();
Expand Down
2 changes: 1 addition & 1 deletion sources/ubuntu-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Fail on first error.
set -e

version=2024.07.06
version=2024.07.16

sourceCodeInstallationDirectory=/usr/local/src/butil
binariesInstallationDirectory=/usr/local/butil
Expand Down

0 comments on commit 0634b52

Please sign in to comment.