delete directory from disk
This commit is contained in:
@@ -17,6 +17,17 @@ public class IdeFileExternalChangeHandler
|
||||
GlobalEvents.Instance.FileSystemWatcherInternal.FileChanged.Subscribe(OnFileChanged);
|
||||
GlobalEvents.Instance.FileSystemWatcherInternal.FileCreated.Subscribe(OnFileCreated);
|
||||
GlobalEvents.Instance.FileSystemWatcherInternal.DirectoryCreated.Subscribe(OnFolderCreated);
|
||||
GlobalEvents.Instance.FileSystemWatcherInternal.DirectoryDeleted.Subscribe(OnFolderDeleted);
|
||||
}
|
||||
|
||||
private async Task OnFolderDeleted(string folderPath)
|
||||
{
|
||||
var sharpIdeFolder = SolutionModel.AllFolders.SingleOrDefault(f => f.Path == folderPath);
|
||||
if (sharpIdeFolder is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
await _sharpIdeSolutionModificationService.RemoveDirectory(sharpIdeFolder);
|
||||
}
|
||||
|
||||
private async Task OnFolderCreated(string folderPath)
|
||||
|
||||
@@ -68,7 +68,16 @@ public sealed class IdeFileWatcher : IDisposable
|
||||
|
||||
private void HandleDeleted(string fullPath)
|
||||
{
|
||||
Console.WriteLine($"FileSystemWatcher: Deleted - {fullPath}");
|
||||
var isDirectory = Path.HasExtension(fullPath) is false;
|
||||
if (isDirectory)
|
||||
{
|
||||
GlobalEvents.Instance.FileSystemWatcherInternal.DirectoryDeleted.InvokeParallelFireAndForget(fullPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalEvents.Instance.FileSystemWatcherInternal.FileDeleted.InvokeParallelFireAndForget(fullPath);
|
||||
}
|
||||
//Console.WriteLine($"FileSystemWatcher: Deleted - {fullPath}");
|
||||
}
|
||||
|
||||
private void HandleCreated(string fullPath)
|
||||
|
||||
@@ -3,6 +3,7 @@ using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||
|
||||
namespace SharpIDE.Application.Features.FileWatching;
|
||||
|
||||
/// Does not do any file system operations, only modifies the in-memory solution model
|
||||
public class SharpIdeSolutionModificationService
|
||||
{
|
||||
public SharpIdeSolutionModel SolutionModel { get; set; } = null!;
|
||||
|
||||
Reference in New Issue
Block a user