Skip to content
This repository was archived by the owner on Mar 3, 2021. It is now read-only.

Conversation

@oneiros
Copy link

@oneiros oneiros commented Jan 23, 2019

#42 added basic directory support that works fine as long as you only use a single directory.

But if you upload files to different directories, FakeFtp::Server#files would list all files as if they resided in the last directory used (aka PWD).

I hope the test case I added further illustrates the issue.

I tried two different approaches before finding this solution.

At first I tried just the changes to FakeFtp::Server#files that are now also in my final solution. But renaming files would not work then, because only the name of the File object was changed, not the file's key in the server's @store.

Then I saw FakeFtp::File#basename and thought there might have been a misunderstanding and the name of the FakeFtp::File should have been a full path. But I quickly found out that this was never the case. FakeFtp::File objects are always instantiated with a normalized "basename". And this is assumed in so many places that trying to change that seemed too complicated.

So I opted to improve renaming of files. I hope my solution is not too far off. I would love feedback either way.

I also removed FakeFtp::File#basename as it had me confused, did in practice never return anything different than #name and was not called anywhere.

Before, `Server#files` only prepended the PWD.
`File`s are always instantiated with a "basename" already.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant