Ejemplo n.º 1
0
        public async Task DeleteFilesAsync(FilePath[] localPaths, bool force, ProgressMonitor monitor, bool keepLocal = true)
        {
            FileUpdateEventArgs args = new FileUpdateEventArgs();
            var metadata             = new DeleteMetadata(VersionControlSystem)
            {
                PathsCount = localPaths.Length, Force = force, KeepLocal = keepLocal
            };

            using (var tracker = Instrumentation.DeleteCounter.BeginTiming(metadata, monitor.CancellationToken)) {
                try {
                    await OnDeleteFilesAsync(localPaths, force, monitor, keepLocal);

                    foreach (var path in localPaths)
                    {
                        args.Add(new FileUpdateEventInfo(this, path, false));
                    }
                } catch (Exception e) {
                    LoggingService.LogError("Failed to delete file", e);
                    metadata.SetFailure();
                    if (!keepLocal)
                    {
                        foreach (var path in localPaths)
                        {
                            File.Delete(path);
                        }
                    }
                }
            }
            ClearCachedVersionInfo(localPaths);
            if (args.Any())
            {
                VersionControlService.NotifyFileStatusChanged(args);
            }
        }
Ejemplo n.º 2
0
        public void DeleteDirectories(FilePath[] localPaths, bool force, ProgressMonitor monitor, bool keepLocal = true)
        {
            var metadata = new DeleteMetadata(VersionControlSystem)
            {
                PathsCount = localPaths.Length, Force = force, KeepLocal = keepLocal
            };

            using (var tracker = Instrumentation.DeleteCounter.BeginTiming(metadata, monitor.CancellationToken)) {
                try {
                    OnDeleteDirectories(localPaths, force, monitor, keepLocal);
                } catch (Exception e) {
                    LoggingService.LogError("Failed to delete directory", e);
                    metadata.SetFailure();
                    if (!keepLocal)
                    {
                        foreach (var path in localPaths)
                        {
                            Directory.Delete(path, true);
                        }
                    }
                }
            }
            ClearCachedVersionInfo(localPaths);
        }