Skip to content

Commit 555ac78

Browse files
committed
Update doc
1 parent edee203 commit 555ac78

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

Doc/library/zipfile.rst

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,15 @@ ZipFile Objects
520520

521521
.. method:: ZipFile.remove(zinfo_or_arcname)
522522

523-
Removes a member from the archive. *zinfo_or_arcname* is either the full
524-
path of the member, or a :class:`ZipInfo` instance.
523+
Removes a member from the archive. *zinfo_or_arcname* may be the full path
524+
of the member or a :class:`ZipInfo` instance.
525+
526+
If multiple members share the same full path, only one is removed when
527+
a path is provided.
528+
529+
This does not physically remove the local file entry from the archive;
530+
the ZIP file size remains unchanged. Use :meth:`ZipFile.repack` afterwards
531+
to reclaim space.
525532

526533
The archive must be opened with mode ``'w'``, ``'x'`` or ``'a'``.
527534

@@ -530,9 +537,20 @@ ZipFile Objects
530537
.. versionadded:: next
531538

532539

533-
.. method:: ZipFile.repack()
540+
.. method:: ZipFile.repack(*, strict_descriptor=False[, chunk_size])
541+
542+
Rewrites the archive to remove local file entries that are no longer
543+
referenced, shrinking the ZIP file size.
544+
545+
``strict_descriptor=True`` can be provided to skip the slower scan for an
546+
unsigned data descriptor (deprecated in the latest ZIP specification and is
547+
only used by legacy tools) when checking for bytes resembling a valid local
548+
file entry before the first referenced entry. This improves performance,
549+
but may cause some stale local file entries to be preserved, as any entry
550+
using an unsigned descriptor cannot be detected.
534551

535-
Repack a zip file and physically remove non-referenced file entries.
552+
*chunk_size* may be specified to control the buffer size when moving
553+
entry data (default is 1 MiB).
536554

537555
The archive must be opened with mode ``'a'``.
538556

0 commit comments

Comments
 (0)