diff options
author | sr55 <[email protected]> | 2017-03-17 21:33:51 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2017-03-17 21:33:58 +0000 |
commit | 82a75bd3d9d5db5432275e9e83e1b65e7b7bdbb6 (patch) | |
tree | 79f95c5655be0821d5a4ff33f43bb3d5f471da5f | |
parent | d9d6e28f2500688d7b6e0fc4b1e5396f237b99cf (diff) |
WinGui: Make the Queue Storage Nightly aware. Also fix an issue with Queue and Log Files not being stored correctly for Portable mode. #267
7 files changed, 25 insertions, 25 deletions
diff --git a/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs b/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs index 0604de331..01dd64667 100644 --- a/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs +++ b/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs @@ -45,7 +45,7 @@ namespace HandBrakeWPF.Helpers {
try
{
- string tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");
+ string tempPath = DirectoryUtilities.GetUserStoragePath(VersionHelper.IsNightly());
List<string> queueFiles = new List<string>();
DirectoryInfo info = new DirectoryInfo(tempPath);
IEnumerable<FileInfo> logFiles = info.GetFiles("*.xml").Where(f => f.Name.StartsWith("hb_queue_recovery"));
@@ -127,7 +127,7 @@ namespace HandBrakeWPF.Helpers /// </returns>
public static bool RecoverQueue(IQueueProcessor encodeQueue, IErrorService errorService, bool silentRecovery)
{
- string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");
+ string appDataPath = DirectoryUtilities.GetUserStoragePath(VersionHelper.IsNightly());
List<string> queueFiles = CheckQueueRecovery();
MessageBoxResult result = MessageBoxResult.None;
if (!silentRecovery)
@@ -173,7 +173,7 @@ namespace HandBrakeWPF.Helpers }
// Recover the Queue
- encodeQueue.RestoreQueue(appDataPath + file);
+ encodeQueue.RestoreQueue(Path.Combine(appDataPath, file));
isRecovered = true;
// Cleanup
diff --git a/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs b/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs index ed06d2cf6..0e84c3650 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs @@ -18,6 +18,8 @@ namespace HandBrakeWPF.Services.Encode using HandBrake.ApplicationServices.Services.Logging; using HandBrake.ApplicationServices.Services.Logging.Interfaces; + using HandBrakeWPF.Utilities; + using EncodeCompletedEventArgs = HandBrakeWPF.Services.Encode.EventArgs.EncodeCompletedEventArgs; using EncodeCompletedStatus = HandBrakeWPF.Services.Encode.Interfaces.EncodeCompletedStatus; using EncodeProgessStatus = HandBrakeWPF.Services.Encode.Interfaces.EncodeProgessStatus; @@ -133,7 +135,7 @@ namespace HandBrakeWPF.Services.Encode { try { - string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs"; + string logDir = DirectoryUtilities.GetLogDirectory(); string encodeDestinationPath = Path.GetDirectoryName(destination); string destinationFile = Path.GetFileName(destination); string encodeLogFile = destinationFile + " " + DateTime.Now.ToString(CultureInfo.InvariantCulture).Replace("/", "-").Replace(":", "-") + ".txt"; diff --git a/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs b/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs index 64d2e6ec9..02a378da7 100644 --- a/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs +++ b/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs @@ -17,6 +17,7 @@ namespace HandBrakeWPF.Services.Queue using System.Xml.Serialization;
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Factories;
using HandBrakeWPF.Services.Encode.Factories;
@@ -215,11 +216,10 @@ namespace HandBrakeWPF.Services.Queue /// </param>
public void BackupQueue(string exportPath)
{
- string appDataPath = Path.Combine(
- Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");
+ string appDataPath = DirectoryUtilities.GetUserStoragePath(VersionHelper.IsNightly());
string tempPath = !string.IsNullOrEmpty(exportPath)
? exportPath
- : appDataPath + string.Format(this.queueFile, string.Empty);
+ : Path.Combine(appDataPath, string.Format(this.queueFile, string.Empty));
using (var strm = new FileStream(tempPath, FileMode.Create, FileAccess.Write))
{
@@ -416,8 +416,7 @@ namespace HandBrakeWPF.Services.Queue /// </param>
public void RestoreQueue(string importPath)
{
- string appDataPath = Path.Combine(
- Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");
+ string appDataPath = DirectoryUtilities.GetUserStoragePath(VersionHelper.IsNightly());
string tempPath = !string.IsNullOrEmpty(importPath)
? importPath
: (appDataPath + string.Format(this.queueFile, string.Empty));
diff --git a/win/CS/HandBrakeWPF/Utilities/GeneralUtilities.cs b/win/CS/HandBrakeWPF/Utilities/GeneralUtilities.cs index 2492de888..1db325ab1 100644 --- a/win/CS/HandBrakeWPF/Utilities/GeneralUtilities.cs +++ b/win/CS/HandBrakeWPF/Utilities/GeneralUtilities.cs @@ -29,7 +29,7 @@ namespace HandBrakeWPF.Utilities /// <summary> /// The Default Log Directory /// </summary> - private static readonly string LogDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs"; + private static readonly string LogDir = DirectoryUtilities.GetLogDirectory(); #endregion diff --git a/win/CS/HandBrakeWPF/Utilities/HandBrakeApp.cs b/win/CS/HandBrakeWPF/Utilities/HandBrakeApp.cs index 5dccba552..8ea5c522e 100644 --- a/win/CS/HandBrakeWPF/Utilities/HandBrakeApp.cs +++ b/win/CS/HandBrakeWPF/Utilities/HandBrakeApp.cs @@ -14,6 +14,8 @@ namespace HandBrakeWPF.Utilities using System.IO;
using System.Linq;
+ using HandBrake.ApplicationServices.Utilities;
+
/// <summary>
/// A general Helper class for HandBrake GUI
/// </summary>
@@ -24,16 +26,15 @@ namespace HandBrakeWPF.Utilities /// </summary>
public static void ResetToDefaults()
{
- DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\presets.xml");
- DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\user_presets.xml");
- DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\settings.xml");
+ string appDataFolder = DirectoryUtilities.GetUserStoragePath(VersionHelper.IsNightly());
+ DeleteFile(Path.Combine(appDataFolder, "presets.json"));
+ DeleteFile(Path.Combine(appDataFolder, "settings.xml"));
- string tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");
- DirectoryInfo info = new DirectoryInfo(tempPath);
+ DirectoryInfo info = new DirectoryInfo(appDataFolder);
IEnumerable<FileInfo> logFiles = info.GetFiles("*.xml").Where(f => f.Name.StartsWith("hb_queue_recovery"));
foreach (FileInfo file in logFiles)
{
- DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\" + file.Name);
+ DeleteFile(Path.Combine(appDataFolder, file.Name));
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs index 572d8a440..ce82439f1 100644 --- a/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs @@ -14,12 +14,11 @@ namespace HandBrakeWPF.ViewModels using System.Text;
using System.Windows;
- using Caliburn.Micro;
-
using HandBrake.ApplicationServices.Services.Logging;
using HandBrake.ApplicationServices.Services.Logging.EventArgs;
using HandBrake.ApplicationServices.Services.Logging.Model;
+ using HandBrakeWPF.Utilities;
using HandBrakeWPF.ViewModels.Interfaces;
using ILog = HandBrake.ApplicationServices.Services.Logging.Interfaces.ILog;
@@ -67,7 +66,7 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public void OpenLogDirectory()
{
- string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
+ string logDir = DirectoryUtilities.GetLogDirectory();
string windir = Environment.GetEnvironmentVariable("WINDIR");
Process prc = new Process { StartInfo = { FileName = windir + @"\explorer.exe", Arguments = logDir } };
prc.Start();
@@ -103,7 +102,7 @@ namespace HandBrakeWPF.ViewModels }
this.OnLogMessageReceived(null);
- this.NotifyOfPropertyChange("ActivityLog");
+ this.NotifyOfPropertyChange(() => this.ActivityLog);
base.OnActivate();
}
@@ -147,7 +146,7 @@ namespace HandBrakeWPF.ViewModels }
}
- this.NotifyOfPropertyChange("ActivityLog");
+ this.NotifyOfPropertyChange(() => this.ActivityLog);
this.OnLogMessageReceived(null);
}
@@ -164,13 +163,12 @@ namespace HandBrakeWPF.ViewModels {
if (this.lastReadIndex < e.Log.MessageIndex)
{
- Execute.OnUIThreadAsync(
- () =>
+ Execute.OnUIThreadAsync(() =>
{
this.lastReadIndex = e.Log.MessageIndex;
this.log.AppendLine(e.Log.Content);
this.OnLogMessageReceived(e);
- this.NotifyOfPropertyChange("ActivityLog");
+ this.NotifyOfPropertyChange(() => this.ActivityLog);
});
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index 45cdcbd1a..48e4e21dd 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -1201,7 +1201,7 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public void ViewLogDirectory()
{
- string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
+ string logDir = DirectoryUtilities.GetLogDirectory();
string windir = Environment.GetEnvironmentVariable("WINDIR");
Process prc = new Process { StartInfo = { FileName = windir + @"\explorer.exe", Arguments = logDir } };
prc.Start();
|