Description
Unfortunately the following code does not behave as expected:
with open(cloud_path, "w") as fp:
fp.write("foo")
(as opposed to using cloud_path.open("w")
which does work as expected).
What will happen is that this will only modify the local cached copy of the file without uploading it to the cloud. Then further attempts to interact with the cloud path will correctly raise OverwriteNewerLocal
exceptions. Because cloud paths have an __fspath__
method (#72) that returns the local file path, the open
function will only interact with that local file path.
Users can still get the correct behavior by using the open
method. However, I've seen a lot of people using regular pathlib, especially those who are still new to it, with open(path, "w")
on their Path
objects, so I expect this may be a common pattern for users of cloudpathlib as well.