Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortherzok <marius.ungureanu@xamarin.com>2019-06-20 16:43:42 +0300
committertherzok <marius.ungureanu@xamarin.com>2019-06-20 16:43:42 +0300
commitec0e96376864611b7cce6b15e5bddd86576277cf (patch)
tree65e4bdf151f0f59ddd9797c417b4fe118a9132a8 /main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs
parent682372f496c10759409f7e51fe4256c47bd666d5 (diff)
Move existence checks for when a file is deleted onto the background thread
Diffstat (limited to 'main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs')
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs33
1 files changed, 26 insertions, 7 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs
index 45139f8c57..e53cda474c 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs
@@ -4516,9 +4516,12 @@ namespace MonoDevelop.Projects
LoggingService.LogError ("OnFileRenamed error.", ex);
}
+ bool exists = File.Exists (sourceFile) || Directory.Exists (sourceFile);
+
Runtime.RunInMainThread (() => {
OnFileCreatedExternally (targetFile);
- OnFileDeletedExternally (sourceFile);
+ if (!exists)
+ OnFileDeletedExternally (sourceFile);
});
}
@@ -4559,14 +4562,34 @@ namespace MonoDevelop.Projects
}
}
+ static readonly ObjectPool<List<FilePath>> filePathListPool = ObjectPool.Create (new PooledListPolicy<FilePath> ());
+
void OnFileDeleted (object sender, FileEventArgs e)
{
if (Runtime.IsMainThread)
return;
+ List<FilePath> paths = null;
+ foreach (var file in e) {
+ var path = file.FileName;
+ bool exists = File.Exists (path) || Directory.Exists (path);
+
+ if (!exists) {
+ paths ??= filePathListPool.Get ();
+ paths.Add (path);
+ }
+ }
+
+ if (paths == null)
+ return;
+
Runtime.RunInMainThread (() => {
- foreach (FileEventInfo info in e) {
- OnFileDeletedExternally (info.FileName);
+ try {
+ foreach (var path in paths) {
+ OnFileDeletedExternally (path);
+ }
+ } finally {
+ filePathListPool.Return (paths);
}
});
}
@@ -4681,10 +4704,6 @@ namespace MonoDevelop.Projects
// the file being saved. Saving with TextFileUtility will result in
// FileService.SystemRename being called to move a temporary file
// to the file being saved which deletes and then creates the file.
- bool notDeleted = File.Exists (fileName) || Directory.Exists (fileName);
- if (notDeleted)
- return;
-
Files.Remove (fileName);
}