Added way to override public directory.

This commit is contained in:
Dario Solera 2011-01-05 15:14:31 +00:00
parent ffa6f12f6b
commit 6b9dd4150b
4 changed files with 24 additions and 24 deletions

View file

@ -16,5 +16,5 @@ using System.Reflection;
// //
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("3.0.4.572")] [assembly: AssemblyVersion("3.0.4.573")]
[assembly: AssemblyFileVersion("3.0.4.572")] [assembly: AssemblyFileVersion("3.0.4.573")]

View file

@ -12,33 +12,13 @@ namespace ScrewTurn.Wiki {
/// </summary> /// </summary>
public abstract class ProviderBase { public abstract class ProviderBase {
private object _syncLock = new object();
private bool _dataDirectoryAlreadyRead = false;
private string _dataDirectory = null;
/// <summary>
/// Sets the data directory.
/// </summary>
/// <param name="dataDirectory">The data directory.</param>
public void SetDataDirectory(string dataDirectory) {
lock(_syncLock) {
if(_dataDirectoryAlreadyRead) throw new InvalidOperationException("Cannot set data directory when it's already been read");
_dataDirectory = dataDirectory;
}
}
/// <summary> /// <summary>
/// Gets the data directory. /// Gets the data directory.
/// </summary> /// </summary>
/// <param name="host">The host object.</param> /// <param name="host">The host object.</param>
/// <returns>The data directory.</returns> /// <returns>The data directory.</returns>
protected string GetDataDirectory(IHostV30 host) { protected string GetDataDirectory(IHostV30 host) {
lock(_syncLock) { return host.GetSettingValue(SettingName.PublicDirectory);
_dataDirectoryAlreadyRead = true;
if(string.IsNullOrEmpty(_dataDirectory)) return host.GetSettingValue(SettingName.PublicDirectory);
else return _dataDirectory;
}
} }
} }

View file

@ -22,6 +22,12 @@ namespace ScrewTurn.Wiki {
private static string version = null; private static string version = null;
/// <summary>
/// A value indicating whether the public directory can still be overridden.
/// </summary>
internal static bool CanOverridePublicDirectory = true;
private static string _overriddenPublicDirectory = null;
/// <summary> /// <summary>
/// Gets the settings storage provider. /// Gets the settings storage provider.
/// </summary> /// </summary>
@ -152,11 +158,23 @@ namespace ScrewTurn.Wiki {
get { return System.Web.HttpRuntime.AppDomainAppPath; } get { return System.Web.HttpRuntime.AppDomainAppPath; }
} }
/// <summary>
/// Overrides the public directory, unless it's too late to do that.
/// </summary>
/// <param name="fullPath">The full path.</param>
internal static void OverridePublicDirectory(string fullPath) {
if(!CanOverridePublicDirectory) throw new InvalidOperationException("Cannot override public directory - that can only be done during Settings Storage Provider initialization");
_overriddenPublicDirectory = fullPath;
}
/// <summary> /// <summary>
/// Gets the Public Directory of the Wiki. /// Gets the Public Directory of the Wiki.
/// </summary> /// </summary>
public static string PublicDirectory { public static string PublicDirectory {
get { get {
if(!string.IsNullOrEmpty(_overriddenPublicDirectory)) return _overriddenPublicDirectory;
string pubDirName = PublicDirectoryName; string pubDirName = PublicDirectoryName;
if(Path.IsPathRooted(pubDirName)) return pubDirName; if(Path.IsPathRooted(pubDirName)) return pubDirName;
else { else {
@ -170,7 +188,7 @@ namespace ScrewTurn.Wiki {
/// <summary> /// <summary>
/// Gets the Public Directory Name (without the full Path) of the Wiki. /// Gets the Public Directory Name (without the full Path) of the Wiki.
/// </summary> /// </summary>
public static string PublicDirectoryName { private static string PublicDirectoryName {
get { get {
string dir = WebConfigurationManager.AppSettings["PublicDirectory"]; string dir = WebConfigurationManager.AppSettings["PublicDirectory"];
if(string.IsNullOrEmpty(dir)) throw new InvalidConfigurationException("PublicDirectory cannot be empty or null"); if(string.IsNullOrEmpty(dir)) throw new InvalidConfigurationException("PublicDirectory cannot be empty or null");

View file

@ -69,6 +69,8 @@ namespace ScrewTurn.Wiki {
ssp.Init(Host.Instance, GetSettingsStorageProviderConfiguration()); ssp.Init(Host.Instance, GetSettingsStorageProviderConfiguration());
Collectors.SettingsProvider = ssp; Collectors.SettingsProvider = ssp;
Settings.CanOverridePublicDirectory = false;
if(!(ssp is SettingsStorageProvider)) { if(!(ssp is SettingsStorageProvider)) {
// Update DLLs from public\Plugins // Update DLLs from public\Plugins
UpdateDllsIntoSettingsProvider(ssp, ProviderLoader.SettingsStorageProviderAssemblyName); UpdateDllsIntoSettingsProvider(ssp, ProviderLoader.SettingsStorageProviderAssemblyName);