Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of IBlobStorage.WriteAsync does not honor the append hint value in FluentFtpBlobStorage #23

Closed
candoumbe opened this issue Jun 2, 2023 · 4 comments
Labels
bug Something isn't working fixed

Comments

@candoumbe
Copy link
Contributor

The current implementation of IBlobStorage.WriteAsyncdoes not honor the append hint value in FluentStorage.FTP implementation

		public async Task WriteAsync(string fullPath, Stream dataStream,
		   bool append = false, CancellationToken cancellationToken = default) {
			AsyncFtpClient client = await GetClientAsync().ConfigureAwait(false);

			await retryPolicy.ExecuteAsync(async () => {
				using (Stream dest = await client.OpenWrite(fullPath, FtpDataType.Binary, true).ConfigureAwait(false)) {
					await dataStream.CopyToAsync(dest).ConfigureAwait(false);
				}
			}).ConfigureAwait(false);
		}

I think the stream should be created using client.OpenAppend when the parameter append is true and client.OpenWrite otherwise.

@candoumbe
Copy link
Contributor Author

candoumbe commented Jun 7, 2023

@robinrodricks
I started working on fixing this bug : develop...candoumbe:FluentStorage:hotfix/ftpblobstorage-should-append-or-write-depending-on-append-parameter-value

Unfortunately, I currently encounter an issue when using TestContainers to setup a FTP fixture (using pure-ftpd docker image) but for now the test fails.

The test passes if I setup a container for the ftp server with a docker compose like this:

  ftpd_server:
    image: stilliard/pure-ftpd
    container_name: pure-ftpd
    ports:
      - "21:21"
      - "30000-30059:30000-30059"
    volumes: # remember to replace /folder_on_disk/ with the path to where you want to store the files on the host machine
      - "/home/<my folder>/data:/home/k2/data:rw"
      - "/home/<my folder>/passwd:/etc/pure-ftpd/passwd"
# uncomment for ssl/tls, see https://github.com/stilliard/docker-pure-ftpd#tls
#      - "/folder_on_disk/ssl:/etc/ssl/private/"
# or ssl/tls with Let's Encrypt (cert and key as two files)
#      - "/etc/letsencrypt/live/<your_server>/cert.pem:/etc/ssl/private/pure-ftpd-cert.pem"
#      - "/etc/letsencrypt/live/<your_server>/privkey.pem:/etc/ssl/private/pure-ftpd-key.pem"
    environment:
      PUBLICHOST: "localhost"
      FTP_USER_NAME: k2
      FTP_USER_PASS: k2
      FTP_USER_HOME: /home/user/
      FTP_MAX_CLIENTS: 50
# also for ssl/tls:
#      ADDED_FLAGS: "--tls=2"
    restart: always

@candoumbe
Copy link
Contributor Author

@robinrodricks
As the PR #25 was merged, when could we expect the hotfix to be available ?

@robinrodricks
Copy link
Owner

I'll do you one better. All released!

@robinrodricks robinrodricks added bug Something isn't working fixed labels Jun 8, 2023
@candoumbe
Copy link
Contributor Author

Thanks @robinrodricks !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants