private CreateSubDirectory ( string name, string localPath ) : |
||
name | string | |
localPath | string | |
return |
private void HandleDirectoryChanged(string path) { // Do these one at a time. lock (directoryChangeLock) { DirectoryInfo info = new DirectoryInfo(path); MFS.IDirectoryItem item = GetFromLocalPath(path); if (item == null && info != null) { // New Directory! MFS.LocalDirectory parentDirectory = GetParentDirectory(info); if (parentDirectory != null) { this.loggingService.LogDebug("NEW DIR !! " + path); parentDirectory.CreateSubDirectory(info.Name, info.FullName); } else { // No parent directory, this happens because // we can get events out of order. this.loggingService.LogDebug("NEW DIR NO PARENT !! " + path); CreateDirectoryForLocalPath(path); } } } }
private void ProcessDirectory(LocalDirectory parentDirectory, IO.DirectoryInfo directoryInfo) { if (parentDirectory == null) { throw new ArgumentNullException("parentDirectory"); } if (directoryInfo == null) { throw new ArgumentNullException("directoryInfo"); } try { if (directoryInfo.Name.StartsWith(".") == false) { LocalDirectory directory = (LocalDirectory)parentDirectory.GetSubdirectory(directoryInfo.Name); if (directory == null) { directory = parentDirectory.CreateSubDirectory(directoryInfo.Name, directoryInfo.FullName); } foreach (IO.FileInfo fileInfo in directoryInfo.GetFiles()) { if (fileInfo.Name.StartsWith(".") == false) { if (IndexingFile != null) IndexingFile(this, fileInfo.FullName); LocalFile file = (LocalFile)directory.GetFile(fileInfo.Name); if (file == null) { file = directory.CreateFile(fileInfo); } else { // XXX: Update file info } if (String.IsNullOrEmpty(file.InfoHash)) { Core.ShareHasher.HashFile(file); } } } foreach (IO.DirectoryInfo subDirectoryInfo in directoryInfo.GetDirectories()) { ProcessDirectory(directory, subDirectoryInfo); } } } catch (ThreadAbortException) { // Canceled, ignore error. } catch (Exception ex) { LoggingService.LogError("Error while re-indexing shared files:", ex); if (ErrorIndexing != null) { ErrorIndexing(this, ex); } } }