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

reset_default_storage_dir gets ignored through get_default_client #414

Open
Quickblink opened this issue Mar 2, 2024 · 1 comment · May be fixed by #436
Open

reset_default_storage_dir gets ignored through get_default_client #414

Quickblink opened this issue Mar 2, 2024 · 1 comment · May be fixed by #436
Labels
good first issue Good for newcomers

Comments

@Quickblink
Copy link

from cloudpathlib.local import LocalS3Path, LocalS3Client

path = LocalS3Path("s3://some/path/")
path.touch()
LocalS3Client.reset_default_storage_dir()
new_path = LocalS3Path("s3://some/path/")
assert not new_path.is_file() # fails

The reason is that reset_default_storage_dir() acts on the class attribute only and not on the instance attribute of the LocalClient in question. Because of Client.get_default_client() returning the same client instance for any path (saved as a class attribute), no new client gets instantiated to make use of the new directory. The tests don’t catch that because they create the clients explicitly.

@pjbull
Copy link
Member

pjbull commented Mar 2, 2024

Thanks @Quickblink, this seems like a real bug.

I believe the easiest way to fix this is to call get_default_client inside reset_default_storage_dir and then also call reset_default_storage_dir on that instance of the client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
2 participants