Example #1
0
        // Moves a directory. This method may be called for versioned and unversioned
        // files. The default implementetions performs a system file move.
        public async Task MoveDirectoryAsync(FilePath localSrcPath, FilePath localDestPath, bool force, ProgressMonitor monitor)
        {
            ClearCachedVersionInfo(localSrcPath, localDestPath);
            var metadata = new MoveMetadata(VersionControlSystem)
            {
                Force = force, OperationType = MoveMetadata.MoveType.Directory
            };

            using (var tracker = Instrumentation.MoveCounter.BeginTiming(metadata, monitor.CancellationToken)) {
                try {
                    await OnMoveDirectoryAsync(localSrcPath, localDestPath, force, monitor);
                } catch (Exception e) {
                    LoggingService.LogError("Failed to move directory", e);
                    metadata.SetFailure();
                    FileService.SystemDirectoryRename(localSrcPath, localDestPath);
                }
            }
        }
Example #2
0
        // Moves a file. This method may be called for versioned and unversioned
        // files. The default implementetions performs a system file move.
        // It's up to the implementation to decide how smart the MoveFile method is.
        // For example, when moving a file to an unversioned directory, the implementation
        // might just throw an exception, or it could version the directory, or it could
        // ask the user what to do.
        public void MoveFile(FilePath localSrcPath, FilePath localDestPath, bool force, ProgressMonitor monitor)
        {
            ClearCachedVersionInfo(localSrcPath, localDestPath);
            var metadata = new MoveMetadata(VersionControlSystem)
            {
                Force = force, OperationType = MoveMetadata.MoveType.File
            };

            using (var tracker = Instrumentation.MoveCounter.BeginTiming(metadata, monitor.CancellationToken)) {
                try {
                    OnMoveFile(localSrcPath, localDestPath, force, monitor);
                } catch (Exception e) {
                    LoggingService.LogError("Failed to move file", e);
                    metadata.SetFailure();
                    File.Move(localSrcPath, localDestPath);
                }
            }
        }