This repository was archived by the owner on Mar 3, 2021. It is now read-only.
Return correct paths when files are uploaded to different directories #55
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#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#fileswould 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#filesthat are now also in my final solution. But renaming files would not work then, because only thenameof theFileobject was changed, not the file's key in the server's@store.Then I saw
FakeFtp::File#basenameand thought there might have been a misunderstanding and thenameof theFakeFtp::Fileshould have been a full path. But I quickly found out that this was never the case.FakeFtp::Fileobjects 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#basenameas it had me confused, did in practice never return anything different than#nameand was not called anywhere.