CmisSync.Lib.Sync.CmisRepo.SynchronizedFolder.ApplyDeletedFiles C# (CSharp) Method

ApplyDeletedFiles() public method

Apply: Deleted files.
public ApplyDeletedFiles ( List &deletedFiles ) : bool
deletedFiles List
return bool
            public bool ApplyDeletedFiles(ref List<string> deletedFiles)
            {
                bool success = true;
                foreach (string deletedFile in deletedFiles)
                {
                    SyncItem deletedItem = SyncItemFactory.CreateFromLocalPath(deletedFile, false, repoInfo, database);
                    try
                    {
                        IDocument deletedDocument = (IDocument)session.GetObjectByPath(deletedItem.RemotePath);

                        // Needed by the normal crawl, but actually not used in our particular case here.
                        IList<string> remoteFiles = new List<string>();
                        try
                        {
                            CrawlRemoteDocument(deletedDocument, deletedItem.RemotePath, deletedItem.LocalPath, remoteFiles);
                        }
                        catch (CmisPermissionDeniedException e)
                        {
                            Logger.Info("This user cannot delete file : " + deletedFile, e);
                            DownloadFile(deletedDocument, deletedItem.RemotePath, deletedItem.LocalPath);
                        }
                    }
                    catch (Exception e)
                    {
                        if (e is ArgumentNullException || e is CmisObjectNotFoundException)
                        {
                            // Typical error when the document does not exist anymore on the server
                            // TODO Make DotCMIS generate a more precise exception.
                            Logger.Info("The document has probably been deleted on the server already: " + deletedFile, e);

                            // Delete local database entry.
                            database.RemoveFile(deletedItem);

                            // Note: This is not a failure per-se, so we don't need to modify the "success" variable.
                        }
                        else
                        {

                            // Could be a network error.
                            Logger.Error("Error applying local file deletion to the server: " + deletedFile, e);
                            success = false;
                        }
                    }
                }
                return success;
            }