Skip to content

Commit

Permalink
Merge pull request #54 from FrendsPlatform/issue-53
Browse files Browse the repository at this point in the history
Files.Copy - Fixed bug with file access
  • Loading branch information
Svenskapojkarna authored Sep 21, 2023
2 parents 6915868 + 70cb4a4 commit 14cffda
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Frends.Files.Copy/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

# [1.0.1] - 2023-09-21
### Fixed
- Fixed bug with file access. Changed File.Open to use FileAccess.Read, because there's no reason to give more access to the Task.

## [1.0.0] - 2023-02-14
### Added
- Initial implementation
7 changes: 5 additions & 2 deletions Frends.Files.Copy/Frends.Files.Copy/Copy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ public class Files
/// Copy files.
/// [Documentation](https://tasks.frends.com/tasks/frends-tasks/Frends.Files.Copy)
/// </summary>
/// <returns>List [ Object { string SourcePath, string Path } ]</returns>
/// <param name="input">Input parameters for the Task.</param>
/// <param name="options">Additional options for the Task.</param>
/// <param name="cancellationToken">CancellationToken given by Frends.</param>
/// <returns>List [ Object { string SourcePath, string TargetPath } ]</returns>
public static async Task<Result> Copy([PropertyTab] Input input, [PropertyTab] Options options, CancellationToken cancellationToken)
{
var result = await ExecuteActionAsync(() => ExecuteCopyAsync(input, options, cancellationToken),
Expand Down Expand Up @@ -99,7 +102,7 @@ private static async Task<List<FileItem>> ExecuteCopyAsync(Input input, Options

private static async Task CopyFileAsync(string source, string destination, CancellationToken cancellationToken)
{
using FileStream sourceStream = File.Open(source, FileMode.Open);
using FileStream sourceStream = File.Open(source, FileMode.Open, FileAccess.Read);
using FileStream destinationStream = File.Open(destination, FileMode.CreateNew);

await sourceStream.CopyToAsync(destinationStream, 81920, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>Latest</LangVersion>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<Authors>Frends</Authors>
<Copyright>Frends</Copyright>
<Company>Frends</Company>
Expand Down

0 comments on commit 14cffda

Please sign in to comment.