public PithosSettings Settings { get; private set; }
- private readonly ConcurrentDictionary<string, PithosMonitor> _monitors = new ConcurrentDictionary<string, PithosMonitor>();
+ private readonly ConcurrentDictionary<Uri, PithosMonitor> _monitors = new ConcurrentDictionary<Uri, PithosMonitor>();
///<summary>
/// Dictionary of account monitors, keyed by account
///</summary>
///</remarks>
// TODO: Does the Shell REALLY need access to the monitors? Could we achieve the same results with a better design?
// TODO: The monitors should be internal to Pithos.Core, even though exposing them makes coding of the Object and Container windows easier
- public ConcurrentDictionary<string, PithosMonitor> Monitors
+ public ConcurrentDictionary<Uri, PithosMonitor> Monitors
{
get { return _monitors; }
}
{
try
{
+ if (Settings.IgnoreCertificateErrors)
+ {
+ ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;
+ }
+
var accounts = Settings.Accounts.Select(MonitorAccount);
await TaskEx.WhenAll(accounts);
_statusService = StatusService.Start();
-/*
- foreach (var account in Settings.Accounts)
- {
- await MonitorAccount(account);
- }
-*/
-
}
catch (AggregateException exc)
{
PithosMonitor monitor;
var accountName = account.AccountName;
- if (_monitors.TryGetValue(accountName, out monitor))
+ if (Monitors.TryGetValue(account.AccountKey, out monitor))
{
//If the account is active
if (account.IsActive)
{
//If the account is inactive
//Stop and remove the monitor
- RemoveMonitor(accountName);
+ RemoveMonitor(account.ServerUrl,accountName);
}
return;
}
monitor.AuthenticationUrl = account.ServerUrl;
- _monitors[accountName] = monitor;
+ Monitors[account.AccountKey] = monitor;
if (account.IsActive)
{
{
if (currentInfo==null)
throw new ArgumentNullException("currentInfo");
- Contract.EndContractBlock();
-
- var monitor = Monitors[currentInfo.Account];
+ Contract.EndContractBlock();
+ var monitor = Monitors[currentInfo.AccountKey];
var newInfo=monitor.CloudClient.GetObjectInfo(currentInfo.Account, currentInfo.Container, currentInfo.Name);
return newInfo;
}
throw new ArgumentNullException("container");
Contract.EndContractBlock();
- var monitor = Monitors[container.Account];
+ var monitor = Monitors[container.AccountKey];
var newInfo = monitor.CloudClient.GetContainerInfo(container.Account, container.Name);
return newInfo;
}
}
- public void RemoveMonitor(string accountName)
+ public void RemoveMonitor(string serverUrl,string accountName)
{
if (String.IsNullOrWhiteSpace(accountName))
return;
- var accountInfo=_accounts.FirstOrDefault(account => account.UserName == accountName);
+ var accountInfo=_accounts.FirstOrDefault(account => account.UserName == accountName && account.StorageUri.ToString().StartsWith(serverUrl));
if (accountInfo != null)
{
_accounts.TryRemove(accountInfo);
_pollAgent.RemoveAccount(accountInfo);
}
+ var accountKey = new Uri(new Uri(serverUrl),accountName);
PithosMonitor monitor;
- if (Monitors.TryRemove(accountName, out monitor))
+ if (Monitors.TryRemove(accountKey, out monitor))
{
monitor.Stop();
//TODO: Also remove any pending actions for this account
#region Event Handlers
public void Handle(SelectiveSynchChanges message)
- {
- var accountName = message.Account.AccountName;
+ {
PithosMonitor monitor;
- if (_monitors.TryGetValue(accountName, out monitor))
+ if (Monitors.TryGetValue(message.Account.AccountKey, out monitor))
{
monitor.SetSelectivePaths(message.Uris,message.Added,message.Removed);