Beispiel #1
0
        public override void MoveDirectory(FilePath sourcePath, FilePath destPath)
        {
            ProgressMonitor monitor = new ProgressMonitor();

            Repository srcRepo = GetRepository(sourcePath);
            Repository dstRepo = GetRepository(destPath);

            if (dstRepo.CanMoveFilesFrom(srcRepo, sourcePath, destPath))
            {
                Task.Run(async() => {
                    Monitor.TryEnter(moveDirectoryLock);
                    try {
                        await srcRepo.MoveDirectoryAsync(sourcePath, destPath, true, monitor);
                    } catch (OperationCanceledException) {
                        return;
                    } catch (Exception e) {
                        LoggingService.LogError("Error while moving directory.", e);
                    } finally {
                        Monitor.Exit(moveDirectoryLock);
                    }
                });
            }
            else
            {
                CopyDirectory(sourcePath, destPath);
                srcRepo.DeleteDirectory(sourcePath, true, monitor, false);
            }
        }
        public override void MoveDirectory(FilePath sourcePath, FilePath destPath)
        {
            ProgressMonitor monitor = new ProgressMonitor();

            Repository srcRepo = GetRepository(sourcePath);
            Repository dstRepo = GetRepository(destPath);

            if (dstRepo.CanMoveFilesFrom(srcRepo, sourcePath, destPath))
            {
                try {
                    srcRepo.MoveDirectoryAsync(sourcePath, destPath, true, monitor).Wait();
                } catch (AggregateException e) {
                    foreach (var inner in e.InnerExceptions)
                    {
                        if (inner is OperationCanceledException)
                        {
                            continue;
                        }
                        LoggingService.LogError("Error while moving directory.", inner);
                    }
                }
            }
            else
            {
                CopyDirectory(sourcePath, destPath);
                srcRepo.DeleteDirectory(sourcePath, true, monitor, false);
            }
        }