-
-
Notifications
You must be signed in to change notification settings - Fork 867
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
[Feature] Distinct SFTP_BASE_URL and [Bugfix] sftp.exists() works incorrectly when using root_path #1363
Comments
@jschneier Additional details about the bugfix. I've just added a couple prints at the start of sftpstorage.py's exists method. This shows the process as it starts with _save() and the recursive _mkdir() calls. I hadn't tried the pre-fix code without the root_path earlier, but I see there's a recursion error there, too. As I see it, there are 2 possible places to address the issue. Either in exists() or in _mkdir().
Scenario 1: Outputs:
Scenario 2: Outputs:
Scenario 3: Outputs:
Scenario 4: Outputs:
|
[Feature]
I'm using Django Storages for both S3 and SFTP, so the fact they both use MEDIA_URL was problematic.
I've added a new setting SFTP_BASE_URL which will be preferred. If it doesn't exist, MEDIA_URL will be used.
And to set it in
[Bug]
Additionally, in implementing the SFTP storage with a root path, the SFTPStorage.exists() would always prepend the root path to what it was checking.
If the root path was
uploads
, it would check for the existence ofuploads/uploads
rather than justuploads
when going through the recursive_mkdir()
calls during a_save()
.This has been fixed by removing the use of self._remote_path(name) within SFTPStorage.exists(), and just returning True if name is falsy.
While in my manual testing in a Django project this works fine both with and without a root path, I have not managed to get tox to run. If someone would help me getting tox up and running, I can add a test for it.
The text was updated successfully, but these errors were encountered: