Make sure that when the directory change happens, any open posts save to the correct location.
This commit is contained in:
parent
6b2d2a079b
commit
f5633a88e4
|
@ -558,7 +558,7 @@ namespace OpenLiveWriter.CoreServices
|
|||
{
|
||||
get
|
||||
{
|
||||
return PreferencesSettingsRoot.GetSubSettings("PostEditor").GetString("PostsDirectory", null); ;
|
||||
return PreferencesSettingsRoot.GetSubSettings("PostEditor").GetString("PostsDirectory", null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -698,6 +698,7 @@ namespace OpenLiveWriter.PostEditor
|
|||
/// the current editing state
|
||||
/// </summary>
|
||||
/// <param name="editingContext">editing conext</param>
|
||||
/// <param name="isNewPost">if set to <c>true</c> [is new post].</param>
|
||||
private void DispatchEditPost(IBlogPostEditingContext editingContext, bool isNewPost)
|
||||
{
|
||||
// calcluate whether the user has a "blank" unsaved post
|
||||
|
@ -754,7 +755,7 @@ namespace OpenLiveWriter.PostEditor
|
|||
else if (saveChangesResult == DialogResult.Yes && editingContext.LocalFile.Equals(LocalFile))
|
||||
{
|
||||
EditPostWithPostCloseEvent(LocalFile.Load());
|
||||
break; ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -206,10 +206,30 @@ namespace OpenLiveWriter.PostEditor
|
|||
private PostEditorFile(DirectoryInfo targetDirectory)
|
||||
{
|
||||
TargetDirectory = targetDirectory;
|
||||
|
||||
ListenForDirectoryChanges();
|
||||
}
|
||||
|
||||
private void ListenForDirectoryChanges()
|
||||
{
|
||||
var preferences = PostEditorPreferences.Instance;
|
||||
|
||||
preferences.PreferencesChanged -= PreferencesOnPreferencesChanged;
|
||||
preferences.PreferencesChanged += PreferencesOnPreferencesChanged;
|
||||
}
|
||||
|
||||
private void PreferencesOnPreferencesChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (TargetDirectory?.FullName != PostEditorSettings.AutoSaveDirectory)
|
||||
{
|
||||
TargetDirectory = new DirectoryInfo(PostEditorPreferences.Instance.WeblogPostsFolder);
|
||||
}
|
||||
}
|
||||
|
||||
private PostEditorFile(FileInfo file)
|
||||
{
|
||||
TargetFile = file;
|
||||
ListenForDirectoryChanges();
|
||||
}
|
||||
|
||||
// auto-create drafts and recent-posts directories
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||
|
||||
using OpenLiveWriter.ApplicationFramework.Preferences;
|
||||
using System;
|
||||
|
||||
namespace OpenLiveWriter.PostEditor
|
||||
{
|
||||
public class PostEditorPreferences : OpenLiveWriter.ApplicationFramework.Preferences.Preferences
|
||||
{
|
||||
private static PostEditorPreferences _instance;
|
||||
|
||||
public static PostEditorPreferences Instance => _instance ?? (_instance = new PostEditorPreferences());
|
||||
|
||||
public PostEditorPreferences() : base("Writer")
|
||||
{
|
||||
}
|
||||
|
@ -74,6 +78,11 @@ namespace OpenLiveWriter.PostEditor
|
|||
}
|
||||
private string _weblogPostsFolder;
|
||||
|
||||
public void Changed()
|
||||
{
|
||||
OnPreferencesChanged(EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected override void LoadPreferences()
|
||||
{
|
||||
PostWindowBehavior = PostEditorSettings.PostWindowBehavior;
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace OpenLiveWriter.PostEditor
|
|||
|
||||
PanelBitmap = ResourceHelper.LoadAssemblyResourceBitmap("Images.PreferencesOther.png");
|
||||
|
||||
_postEditorPreferences = new PostEditorPreferences();
|
||||
_postEditorPreferences = PostEditorPreferences.Instance;
|
||||
_postEditorPreferences.PreferencesModified += _writerPreferences_PreferencesModified;
|
||||
|
||||
switch (_postEditorPreferences.PostWindowBehavior)
|
||||
|
@ -160,7 +160,7 @@ namespace OpenLiveWriter.PostEditor
|
|||
Directory.CreateDirectory(destinationRecentPosts);
|
||||
Directory.CreateDirectory(destinationDrafts);
|
||||
|
||||
if (String.Compare(_originalFolder, _postEditorPreferences.WeblogPostsFolder, true) != 0)
|
||||
if (string.Compare(_originalFolder, _postEditorPreferences.WeblogPostsFolder, true, CultureInfo.CurrentUICulture) != 0)
|
||||
{
|
||||
string message = "You have updated the default location for your blog posts, would you like to move any existing posts?";
|
||||
string caption = "Move existing posts";
|
||||
|
@ -175,6 +175,8 @@ namespace OpenLiveWriter.PostEditor
|
|||
|
||||
MovePosts(Path.Combine(_originalFolder + @"\\Drafts\\"), destinationDrafts);
|
||||
}
|
||||
|
||||
_postEditorPreferences.Changed();
|
||||
}
|
||||
|
||||
if (_postEditorPreferences.IsModified())
|
||||
|
|
Loading…
Reference in New Issue