X-Git-Url: https://code.grnet.gr/git/pithos-ms-client/blobdiff_plain/5d7b20e82e4d1fd45c85b289881b210228efb5a6..4671d60635fd4da7bcad87ca46c0181c16d33f36:/trunk/Pithos.Core/Agents/FileAgent.cs diff --git a/trunk/Pithos.Core/Agents/FileAgent.cs b/trunk/Pithos.Core/Agents/FileAgent.cs index 8b5c612..b64773a 100644 --- a/trunk/Pithos.Core/Agents/FileAgent.cs +++ b/trunk/Pithos.Core/Agents/FileAgent.cs @@ -93,23 +93,23 @@ namespace Pithos.Core.Agents { if (change.ChangeType == WatcherChangeTypes.Renamed) { - var rename = (RenamedEventArgs) change; - _agent.Post(new WorkflowState + var rename = (MovedEventArgs) change; + _agent.Post(new WorkflowState(change) { AccountInfo = AccountInfo, OldPath = rename.OldFullPath, - OldFileName = rename.OldName, + OldFileName = Path.GetFileName(rename.OldName), Path = rename.FullPath, - FileName = rename.Name, + FileName = Path.GetFileName(rename.Name), TriggeringChange = rename.ChangeType }); } else - _agent.Post(new WorkflowState + _agent.Post(new WorkflowState(change) { AccountInfo = AccountInfo, Path = change.FullPath, - FileName = change.Name, + FileName = Path.GetFileName(change.Name), TriggeringChange = change.ChangeType }); } @@ -219,12 +219,14 @@ namespace Pithos.Core.Agents public string CachePath { get; set; } - private List _selectivePaths = new List(); + /*private List _selectivePaths = new List(); public List SelectivePaths { get { return _selectivePaths; } set { _selectivePaths = value; } } +*/ + public Selectives Selectives { get; set; } public void Post(WorkflowState workflowState) @@ -309,11 +311,13 @@ namespace Pithos.Core.Agents return true; if (_ignoreFiles.ContainsKey(filePath.ToLower())) return true; - + + //If selective sync is enabled, propagate folder events + if (Selectives.IsSelectiveEnabled(AccountInfo.AccountKey) && Directory.Exists(filePath)) + return false; //Ignore if selective synchronization is defined, - return SelectivePaths.Count > 0 - //And the target file is not below any of the selective paths - && !SelectivePaths.Any(filePath.IsAtOrDirectlyBelow); + //And the target file is not below any of the selective paths + return !Selectives.IsSelected(AccountInfo, filePath); } /* private static bool FoundInRoot(string filePath, string rootPath) @@ -489,17 +493,19 @@ namespace Pithos.Core.Agents if (Directory.Exists(path)) return state; - var info = new FileInfo(path); - StatusNotification.Notify(new StatusNotification(String.Format("Hashing [{0}]",info.Name))); - var shortHash = info.ComputeShortHash(); - - string merkleHash = info.CalculateHash(StatusKeeper.BlockSize,StatusKeeper.BlockHash); - StatusKeeper.UpdateFileChecksum(path,shortHash, merkleHash); + using (StatusNotification.GetNotifier("Hashing {0}", "Finished Hashing {0}", info.Name)) + { - state.Hash = merkleHash; - return state; + var shortHash = info.ComputeShortHash(); + + string merkleHash = info.CalculateHash(StatusKeeper.BlockSize, StatusKeeper.BlockHash); + StatusKeeper.UpdateFileChecksum(path, shortHash, merkleHash); + + state.Hash = merkleHash; + return state; + } } //Does the file exist in the container's local folder? @@ -555,6 +561,8 @@ namespace Pithos.Core.Agents public void Delete(string relativePath) { var absolutePath = Path.Combine(RootPath, relativePath).ToLower(); + if (Log.IsDebugEnabled) + Log.DebugFormat("Deleting {0}", absolutePath); if (File.Exists(absolutePath)) { try