fake_ftp
fake_ftp copied to clipboard
Return correct paths when files are uploaded to different directories
#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.