}
+
+
private IPithosWorkflow _workflow;
[Import]
[Import]
public NetworkAgent NetworkAgent { get; set; }
[Import]
- public PollAgent PollAgent { get; set; }
+ public PollAgent PollAgent { get; set; }
+
+ private Selectives _selectives;
+
+ [Import]
+ public Selectives Selectives
+ {
+ get { return _selectives; }
+ set
+ {
+ _selectives = value;
+ FileAgent.Selectives = value;
+ }
+ }
public string UserName { get; set; }
private string _apiKey;
public PithosMonitor()
{
- FileAgent = new FileAgent((int)Settings.FileIdleTimeout.TotalMilliseconds);
-
+ FileAgent = new FileAgent();
}
private bool _started;
}
_cancellationSource = new CancellationTokenSource();
-
- CloudClient = new CloudFilesClient(UserName, ApiKey)
- {UsePithos = true, AuthenticationUrl = AuthenticationUrl};
-
-
- _accountInfo = CloudClient.Authenticate();
+ lock (this)
+ {
+ CloudClient = new CloudFilesClient(UserName, ApiKey)
+ {UsePithos = true, AuthenticationUrl = AuthenticationUrl};
+ _accountInfo = CloudClient.Authenticate();
+ }
_accountInfo.SiteUri = AuthenticationUrl;
_accountInfo.AccountPath = RootPath;
StatusKeeper.StartProcessing(_cancellationSource.Token);
IndexLocalFiles();
//Extract the URIs from the string collection
- var settings = Settings.Accounts.First(s => s.AccountName == _accountInfo.UserName);
+ var settings = Settings.Accounts.First(s => s.AccountKey == _accountInfo.AccountKey );
var selectiveUrls=settings.SelectiveFolders.Cast<string>().Select(url => new Uri(url)).ToArray();
SetSelectivePaths(selectiveUrls,null,null);
}
}*/
- internal class LocalFileComparer:EqualityComparer<CloudAction>
- {
- public override bool Equals(CloudAction x, CloudAction y)
- {
- if (x.Action != y.Action)
- return false;
- if (x.LocalFile != null && y.LocalFile != null && !x.LocalFile.FullName.Equals(y.LocalFile.FullName))
- return false;
- if (x.CloudFile != null && y.CloudFile != null )
- {
- if (x.CloudFile.Hash == null & y.CloudFile.Hash != null)
- return false;
- if (x.CloudFile.Hash != null & y.CloudFile.Hash == null)
- return false;
- if (x.CloudFile.Hash == null & y.CloudFile.Hash == null)
- return (x.CloudFile.Name == y.CloudFile.Name);
- if (!x.CloudFile.Hash.Equals(y.CloudFile.Hash))
- return false;
- }
- if (x.CloudFile == null ^ y.CloudFile == null ||
- x.LocalFile == null ^ y.LocalFile == null)
- return false;
- return true;
- }
-
- public override int GetHashCode(CloudAction obj)
- {
- if (obj == null)
- return 0;
- var hash1 = (obj.LocalFile == null) ? int.MaxValue : obj.LocalFile.FullName.GetHashCode();
- var hash2 = (obj.CloudFile == null) ? int.MaxValue : (obj.CloudFile.Hash ?? obj.CloudFile.Name??"").GetHashCode();
- var hash3 = obj.Action.GetHashCode();
- return hash1 ^ hash2 & hash3;
- }
- }
-
private void StartNetworkAgent()
{
Log.DebugFormat("Start Folder Monitoring [{0}]",RootPath);
AgentLocator<FileAgent>.Register(FileAgent,RootPath);
-
+
+ FileAgent.IdleTimeout = Settings.FileIdleTimeout;
FileAgent.StatusKeeper = StatusKeeper;
FileAgent.StatusNotification = StatusNotification;
FileAgent.Workflow = Workflow;
//Convert the uris to paths
var selectivePaths = UrisToFilePaths(uris);
- FileAgent.SelectivePaths=selectivePaths;
- PollAgent.SetSyncUris(uris);
-
+ var selectiveUri = uris.ToList();
+ this.Selectives.SetSelectedUris(_accountInfo,selectiveUri);
+
var removedPaths = UrisToFilePaths(removed);
UnversionSelectivePaths(removedPaths);
if (uris == null)
return new List<string>();
- return (from uri in uris
- let relativePath = _accountInfo.StorageUri
- .MakeRelativeUri(uri)
- .RelativeUriToFilePath()
- //Trim the account name
- select Path.Combine(RootPath, relativePath.After(_accountInfo.UserName + '\\'))).ToList();
+ var own = (from uri in uris
+ where uri.ToString().StartsWith(_accountInfo.StorageUri.ToString())
+ let relativePath = _accountInfo.StorageUri.MakeRelativeUri(uri).RelativeUriToFilePath()
+ //Trim the account name
+ select Path.Combine(RootPath, relativePath.After(_accountInfo.UserName + '\\'))).ToList();
+ var others= (from uri in uris
+ where !uri.ToString().StartsWith(_accountInfo.StorageUri.ToString())
+ let relativePath = _accountInfo.StorageUri.MakeRelativeUri(uri).RelativeUriToFilePath()
+ //Trim the account name
+ select Path.Combine(RootPath,"others-shared", relativePath)).ToList();
+ return own.Union(others).ToList();
}