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

ZipFile don't overwrite compresed files at create #55624

Closed
piranna mannequin opened this issue Mar 6, 2011 · 4 comments
Closed

ZipFile don't overwrite compresed files at create #55624

piranna mannequin opened this issue Mar 6, 2011 · 4 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@piranna
Copy link
Mannequin

piranna mannequin commented Mar 6, 2011

BPO 11415
Nosy @terryjreedy, @amauryfa
Superseder
  • bpo-6818: remove/delete method for zipfile/tarfile objects
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2011-03-19.05:07:47.432>
    created_at = <Date 2011-03-06.18:24:12.786>
    labels = ['type-bug', 'invalid']
    title = "ZipFile don't overwrite compresed files at create"
    updated_at = <Date 2011-03-19.05:07:47.430>
    user = 'https://bugs.python.org/piranna'

    bugs.python.org fields:

    activity = <Date 2011-03-19.05:07:47.430>
    actor = 'terry.reedy'
    assignee = 'none'
    closed = True
    closed_date = <Date 2011-03-19.05:07:47.432>
    closer = 'terry.reedy'
    components = []
    creation = <Date 2011-03-06.18:24:12.786>
    creator = 'piranna'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 11415
    keywords = []
    message_count = 4.0
    messages = ['130182', '130254', '130255', '131388']
    nosy_count = 3.0
    nosy_names = ['terry.reedy', 'amaury.forgeotdarc', 'piranna']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = None
    status = 'closed'
    superseder = '6818'
    type = 'behavior'
    url = 'https://bugs.python.org/issue11415'
    versions = []

    @piranna
    Copy link
    Mannequin Author

    piranna mannequin commented Mar 6, 2011

    I've created a new, compresed ZipFile in memory (using StringIO) and added several files to it with ZipFile.write(), later i've added a new file with the same name of one of the previous ones just to overwrite it with some dinamic data using ZipFile.writestr(), and finally i've closed the StringIO ZipFile and writen to the hard disk.

    Secondly, i've opened it with FileRoller and found that the overwritten file is twice inside the ZipFile, the first and the second one, with different sizes and timestamp. Luckily, extracting one of them just get only the more recent one, but the fact is that the old one is already there and it's listed instead being overwritten with the last, new one, and i don't know if it's a bug (i think so) or just a feature.

    @piranna piranna mannequin added the type-bug An unexpected behavior, bug, or error label Mar 6, 2011
    @amauryfa
    Copy link
    Member

    amauryfa commented Mar 7, 2011

    Luckily, extracting one of them just get only the more recent one

    It's not only luck: a Zip file has a "central directory" used to retrieve data. ZipFile just appends the new file data to the end of the Zip file, then write the updated directory structure.

    Removing the old content is another matter, and is similar to bpo-6818.
    This requires a whole copy of the zip file, and so far, no acceptable patch was proposed.

    @piranna
    Copy link
    Mannequin Author

    piranna mannequin commented Mar 7, 2011

    Ok, they talk about remove it, that's why i didn't found it :-P Ok, it make sense. By the way, this way the old data is available? How? (Just to know... it could be a courious feature :-D )

    @terryjreedy
    Copy link
    Member

    2.6 is only open for security fixes.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants