CmisSync.Lib.Sync.CmisRepo.SynchronizedFolder.CrawlRemote C# (CSharp) Метод

CrawlRemote() приватный Метод

Crawl remote content, syncing down if needed. Meanwhile, cache remoteFiles and remoteFolders, they are output parameters that are used in CrawlLocalFiles/CrawlLocalFolders
private CrawlRemote ( IFolder remoteFolder, string remotePath, string localFolder, IList remoteFiles, IList remoteFolders ) : bool
remoteFolder IFolder
remotePath string
localFolder string
remoteFiles IList
remoteFolders IList
Результат bool
            private bool CrawlRemote(IFolder remoteFolder, string remotePath, string localFolder, IList<string> remoteFiles, IList<string> remoteFolders)
            {
                bool success = true;
                SleepWhileSuspended();

                // Remember seen names, and depending on the profile ignore the ones that have appeared already.
                // For instance, if the CMIS server has a file called Hello and a folder called HELLO, then on Windows the paths would conflict.
                // Store lowercase file and folder names inside.
                HashSet<string> names = new HashSet<string>();

                // Get all remote children.
                // TODO: use paging
                IOperationContext operationContext = session.CreateOperationContext();
                this.repoInfo.CmisProfile.ConfigureOperationContext(operationContext);
                operationContext.MaxItemsPerPage = Int32.MaxValue;
                foreach (ICmisObject cmisObject in remoteFolder.GetChildren(operationContext))
                {
                    try
                    {
                        if (cmisObject is DotCMIS.Client.Impl.Folder)
                        {
                            // It is a CMIS folder.
                            IFolder remoteSubFolder = (IFolder)cmisObject;
                            string remoteSubPath = CmisUtils.PathCombine(remotePath, remoteSubFolder.Name);
                            if (repoInfo.CmisProfile.IgnoreIfSameLowercaseNames && names.Contains(remoteSubFolder.Name.ToLowerInvariant()))
                            {
                                Logger.Warn("Ignoring " + remoteSubFolder.Name + "because other file or folder has the same name when ignoring lowercase/uppercase");
                            }
                            else
                            {
                                CrawlRemoteFolder(remoteSubFolder, remoteSubPath, localFolder, remoteFolders);
                                names.Add(remoteSubFolder.Name.ToLowerInvariant());
                            }
                        }
                        else if (cmisObject is DotCMIS.Client.Impl.Document)
                        {
                            // It is a CMIS document.
                            IDocument remoteDocument = (IDocument)cmisObject;
                            string remoteDocumentPath = CmisUtils.PathCombine(remotePath, remoteDocument.Name);
                            if (repoInfo.CmisProfile.IgnoreIfSameLowercaseNames && names.Contains(remoteDocument.Name.ToLowerInvariant()))
                            {
                                Logger.Warn("Ignoring " + remoteDocument.Name + "because other file or folder has the same name when ignoring lowercase/uppercase");
                            }
                            else
                            {
                                CrawlRemoteDocument(remoteDocument, remoteDocumentPath, localFolder, remoteFiles);
                                names.Add(remoteDocument.Name.ToLowerInvariant());
                            }
                        }
                        else if (isLink(cmisObject))
                        {
                            Logger.Debug("Ignoring file '" + remoteFolder + "/" + cmisObject.Name + "' of type '" +
                                cmisObject.ObjectType.Description + "'. Links are not currently handled.");
                        }
                        else
                        {
                            Logger.Warn("Unknown object type: '" + cmisObject.ObjectType.Description + "' (" + cmisObject.ObjectType.DisplayName
                                + ") for object " + remoteFolder + "/" + cmisObject.Name);
                        }
                    }
                    catch (CmisBaseException e)
                    {
                        ProcessRecoverableException("Could not access remote object: " + cmisObject.Name, e);
                        success = false;
                    }
                }
                return success;
            }