Пример #1
0
        /// <inheritdoc />
        protected override Task <PlaceFileResult> PlaceFileCoreAsync(
            OperationContext operationContext,
            ContentHash contentHash,
            AbsolutePath path,
            FileAccessMode accessMode,
            FileReplacementMode replacementMode,
            FileRealizationMode realizationMode,
            UrgencyHint urgencyHint,
            Counter retryCounter)
        {
            if (replacementMode != FileReplacementMode.ReplaceExisting && FileSystem.FileExists(path))
            {
                if (replacementMode == FileReplacementMode.SkipIfExists)
                {
                    return(Task.FromResult(new PlaceFileResult(PlaceFileResult.ResultCode.NotPlacedAlreadyExists)));
                }
                else if (replacementMode == FileReplacementMode.FailIfExists)
                {
                    return(Task.FromResult(new PlaceFileResult(
                                               PlaceFileResult.ResultCode.Error,
                                               $"File exists at destination {path} with FailIfExists specified")));
                }
            }

            return(PerformRetries(
                       operationContext,
                       () => RpcClient.PlaceFileAsync(operationContext, contentHash, path, accessMode, replacementMode, realizationMode),
                       retryCounter: retryCounter));
        }