private void HandleDirecortyChange(FileSystemEventArgs e) { string fn = Path.GetFileName(PathHelper.GetLongPath(e.FullPath)); switch (e.ChangeType) { case WatcherChangeTypes.Created: string relativeFolder = FolderRelativePath + Path.DirectorySeparatorChar + e.Name; RepositoryFolder <T> subfolder = new RepositoryFolder <T>(SolutionRepository, mSolutionRepositoryItemInfo, ItemFilePattern, relativeFolder, ContainsRepositoryItems, null); GetSubFolders().Add(subfolder); break; case WatcherChangeTypes.Changed: // change happen when new file is added, for now we can ignore, as we will get also file added event break; case WatcherChangeTypes.Deleted: RepositoryFolder <T> sf2 = GetSubFolder(fn); sf2.DeleteFolderCacheItemsRecursive(); //delete the folder from folders cache if (mSubFoldersCache != null) { mSubFoldersCache.Remove(sf2); } break; } SolutionRepository.RefreshParentFoldersSoucerControlStatus(e.FullPath); return; }
private void HandleFileChange(FileSystemEventArgs e) { if (IsRepositoryFile(e.FullPath)) { RepositoryItemBase item = null; switch (e.ChangeType) { case WatcherChangeTypes.Changed: WaitforFileIsReadable(e.FullPath); // reLoad the object to mem updating fields item = GetItemFromCacheByFileName(e.FullPath); NewRepositorySerializer.ReloadObjectFromFile(item); item.RefreshSourceControlStatus(); break; case WatcherChangeTypes.Deleted: //remove from cache and list item = GetItemFromCacheByFileName(e.FullPath); RemoveItemFromLists(item); break; case WatcherChangeTypes.Created: WaitforFileIsReadable(e.FullPath); // add item to cache and list T newItem = LoadItemfromFile <T>(e.FullPath, Path.GetDirectoryName(e.FullPath)); AddItemtoCache(e.FullPath, newItem); mFolderItemsList.Add(newItem); break; } } SolutionRepository.RefreshParentFoldersSoucerControlStatus(Path.GetDirectoryName(e.FullPath)); }
private void HandleDirecortyChange(FileSystemEventArgs e) { string fn = Path.GetFileName(PathHelper.GetLongPath(e.FullPath)); switch (e.ChangeType) { case WatcherChangeTypes.Created: string relativeFolder = FolderRelativePath + Path.DirectorySeparatorChar + e.Name; RepositoryFolder <T> subfolder = new RepositoryFolder <T>(SolutionRepository, mSolutionRepositoryItemInfo, ItemFilePattern, relativeFolder, ContainsRepositoryItems, null); GetSubFolders().Add(subfolder); break; case WatcherChangeTypes.Changed: // change happen when new file is added, for now we can ignore, as we will get also file added event //if the folder is deleted(shift + del) by the user from the file system and not from Ginger //it comes as changed first then goes to deledted so need to stop/pause file watcher so that the folder should get deleted from the file system RepositoryFolder <T> repositoryFolder = GetSubFolder(fn); if (repositoryFolder != null) { repositoryFolder.PauseFileWatcher(); if (Directory.Exists(e.FullPath)) { repositoryFolder.ResumeFileWatcher(); } } break; case WatcherChangeTypes.Deleted: RepositoryFolder <T> repositoryFolder1 = GetSubFolder(fn); if (repositoryFolder1 != null) { repositoryFolder1.DeleteFolderCacheItemsRecursive(); //delete the folder from folders cache if (mSubFoldersCache != null) { mSubFoldersCache.Remove(repositoryFolder1); } } break; } SolutionRepository.RefreshParentFoldersSoucerControlStatus(e.FullPath); return; }