示例#1
0
    internal Result TransferFile(Args args)
    {
        var convertResult = _cameraFileNameConverter.Convert(args);

        if (convertResult.IsFailure)
        {
            return(convertResult);
        }

        var(destinationDirectory, destinationFileName) = convertResult.Value;
        if (!_fileSystem.Directory.Exists(destinationDirectory) && !args.DryRun)
        {
            _fileSystem.Directory.CreateDirectory(destinationDirectory);
            OnDirectoryCreated(this, destinationDirectory);
        }

        var destinationFilePath =
            new CameraFilePath(_fileSystem.Path.Combine(destinationDirectory, destinationFileName));
        var destinationAlreadyExists = _fileSystem.File.Exists(destinationFilePath);

        if (destinationAlreadyExists && !args.Overwrite)
        {
            OnFileSkipped(this, (args.CameraFilePath, destinationFilePath));
            return(Result.Success());
        }

        if (!args.DryRun)
        {
            _transferFiles(args.CameraFilePath, destinationFilePath, args.Overwrite);
        }

        OnFileTransferred(this, (args.CameraFilePath, destinationFilePath, args.DryRun));
        return(Result.Success());
    }
示例#2
0
 private IEnumerable <FileSkippedEventHandler> FileSkippedEventHandlers()
 {
     return(from d in OnFileSkipped.GetInvocationList() select(FileSkippedEventHandler) d);
 }