// For this job if the parent node has all properties updated then we keep going up, this variable stores the last parent that got updated protected override object DoJob() { if (_manager.GetAclProperty) { _currentNode.Acls = _manager.Client.GetAclStatus(_currentNode.FullPath); } if (_currentNode.Type == DirectoryEntryType.DIRECTORY) { var fop = _manager.Client.EnumerateDirectory(_currentNode.FullPath); foreach (var dir in fop) { if (dir.Type == DirectoryEntryType.DIRECTORY) { _currentNode.ChildDirectoryNodes.Add(new PropertyTreeNode(dir.FullName, dir.Type, dir.Length, _currentNode, _manager.DisplayFiles || _manager.GetAclProperty)); _currentNode.DirectChildDirec++; } else { _currentNode.DirectChildSize += dir.Length; _currentNode.DirectChildFiles++; if (_manager.DisplayFiles) { _currentNode.ChildFileNodes.Add( new PropertyTreeNode(dir.FullName, dir.Type, dir.Length, _currentNode)); } } } if (_manager.GetSizeProperty) { _currentNode.TotChildSize += _currentNode.DirectChildSize; _currentNode.TotChildDirec += _currentNode.DirectChildDirec; _currentNode.TotChildFiles += _currentNode.DirectChildFiles; } // Add the jobs for child nodes after we have enumerated all the sub-directories to be threadsafe foreach (var childNode in _currentNode.ChildDirectoryNodes) { _manager.ConsumerQueue.Add(new EnumerateAndGetPropertyJob(childNode, _manager)); } if (_manager.GetAclProperty) { foreach (var childNode in _currentNode.ChildFileNodes) { _manager.ConsumerQueue.Add(new EnumerateAndGetPropertyJob(childNode, _manager)); } } // If it is the root node if (_currentNode.DepthLevel == 0) { // If no subdirectories and we are only retrieving disk usage then end // for acl if there are no sub directories and sub files then only end if (!_manager.GetAclProperty && _currentNode.ChildDirectoryNodes.Count == 0 || (_manager.GetAclProperty && _currentNode.NoChildren())) { _manager.ConsumerQueue.Add(new PoisonJob()); } return(null); } } UpdateParentProperty(_currentNode, true); return(null); }
// For this job if the parent node has all properties updated then we keep going up, this variable stores the last parent that got updated protected override object DoJob() { if (_manager.GetAclProperty) { _currentNode.Acls = _manager.Client.GetAclStatus(_currentNode.FullPath); } if (_currentNode.Type == DirectoryEntryType.DIRECTORY) { var fop = _manager.Client.EnumerateDirectory(_currentNode.FullPath); foreach (var dir in fop) { if (dir.Type == DirectoryEntryType.DIRECTORY) { _currentNode.ChildDirectoryNodes.Add(new PropertyTreeNode(dir.FullName, dir.Type, dir.Length, _currentNode, _manager.GetAclProperty || _manager.DisplayFiles)); _currentNode.DirectChildDirec++; } else { _currentNode.DirectChildSize += dir.Length; _currentNode.DirectChildFiles++; // We need to add files to list only if user has specified DisplayFiles if (_manager.DisplayFiles) { _currentNode.ChildFileNodes.Add( new PropertyTreeNode(dir.FullName, dir.Type, dir.Length, _currentNode)); } } } if (_manager.GetSizeProperty) { _currentNode.TotChildSize += _currentNode.DirectChildSize; _currentNode.TotChildDirec += _currentNode.DirectChildDirec; _currentNode.TotChildFiles += _currentNode.DirectChildFiles; } // Add the jobs for child nodes after we have enumerated all the sub-directories to be threadsafe foreach (var childNode in _currentNode.ChildDirectoryNodes) { _manager.ConsumerQueue.Add(new EnumerateAndGetPropertyJob(childNode, _manager)); } // REMEMBER if user has not specified DISPLAYFILES we would not compute ACL for the file // _currentNode.ChildFileNodes will be empty if user has not passed DisplayFiles // Reason is there can be millions of files and there will be unnecessary delay in getting Acls even though user does not want acl of files if (_manager.GetAclProperty) { foreach (var childNode in _currentNode.ChildFileNodes) { _manager.ConsumerQueue.Add(new EnumerateAndGetPropertyJob(childNode, _manager)); } } } // Putting this outside because input can be a file also // If it is the root node then enter here. If the input is a file then it will exit before updating the parent property if (_currentNode.DepthLevel == 0) { // For only disk usage (no getacl) if no subdirectories then end // for getacl if there are no sub directories and sub files then only end if (!_manager.GetAclProperty && _currentNode.ChildDirectoryNodes.Count == 0 || (_manager.GetAclProperty && _currentNode.NoChildren())) { _manager.ConsumerQueue.Add(new PoisonJob()); } return(null); } UpdateParentProperty(_currentNode, true); return(null); }