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

ZipFS cannot remove files #566

Open
JustASquid opened this issue Feb 23, 2023 · 0 comments
Open

ZipFS cannot remove files #566

JustASquid opened this issue Feb 23, 2023 · 0 comments

Comments

@JustASquid
Copy link

It would appear that the ZipFS simply lacks the ability to remove files.

with tempfile.TemporaryDirectory() as tmp_path:
    tmp_path = Path(tmp_path)
    with zipfile.ZipFile(tmp_path / "test.zip", "w") as zf:
        zf.writestr("1.txt", "Some zip contents")

    with ZipFS(str(tmp_path / "test.zip"), write=True) as zf:
        print(zf.tree())
        zf.remove("1.txt")

On OSX, this gives the error:

FileNotFoundError: [Errno 2] No such file or directory: b'/var/folders/00/kpyxc1gs2x7fm7g6r1_h5mcc0000gp/T/tmpdjec5u7t__ziptemp__/1.txt'

Since it would seem that the implementation of the WriteZipFS is just to create an empty temp directory and then zip it up when it's done, it makes sense that removing files from an existing archive wouldn't work... Perhaps it should copy any existing files from the zip into the temp FS when it's created?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant