Skip to content

ZIP append mode cannot create a missing archive #2138

Description

@pentaoa

ZIP append mode fails when the target archive does not exist. The underlying file is always opened as r+b, which raises before zipfile.ZipFile(mode="a") can create the archive. This affects both local paths and memory URLs.

import fsspec
fs = fsspec.filesystem("zip", fo="memory://new.zip", mode="a")
# FileNotFoundError: /new.zip

Expected: create the archive, then allow entries to be written. This is the behavior of Python’s zipfile.ZipFile(..., mode="a"). Appending to an existing archive must preserve its existing entries.

Reproduced on current main, Python 3.12.12, macOS arm64. A regression using a tiny archive fails for both local and memory filesystems.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions