You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by eg <eg...@gmail.com> on 2008/10/28 06:16:22 UTC

[PATCH] Fix hot-backup.py issue where zip archives do not backup empty directories

Neels J. Hofmeyr wrote:

> 
> I took a look at the python documentation, and it says this:
> 
> [[[
> [ZipFile.]writestr( zinfo_or_arcname, bytes)
>     Write the string bytes to the archive; zinfo_or_arcname is either the
> file name it will be given in the archive, or a ZipInfo instance. If it's an
> instance, at least the filename, date, and time must be given. If it's a
> name, the date and time is set to the current date and time. The archive
> must be opened with mode 'w' or 'a'.
> ]]]
> 
> Have you paid attention to the date and time stuff?
> 
> When I test your patch on GNU/Linux, empty directories are added with a date
> of 1980-01-01 00:00, which is not what the writestr() documentation says (if
> I understand that correctly).

hmmm... I must have mixed up reading the zinfo vs filename
initialization logic in the help string. In the zinfo case, giving no
time/date initializes it to 0 time which corresponds to the 1980-01-01
date/time. Not what the function needs nor what we want.

> 
> Could you please investigate? We're close to a commit, but the date/time
> thing would be nice to clarify: Either fix it, or find a good reason why
> it's not needed.


I have fixed it in the attached patch.


> I'll commit as soon as the date/time thing is reviewed/resolved.

Thanks for your help and patience on this.

> 
> For the record: while my `unzip' commandline tool successfully creates the
> empty directories as above, the Gnome Archive Manager fails to list them (so
> it's kind of a special case). I'd encourage using bz2 or gz instead. Most MS
> Windows software supports these archive types, so there's really no need to
> use zip archives in the first place (right?).
> 

I did my testing with both 7-zip and winzip under WindowsXp and they
both re-create the directories correctly too. I also did a quick test 
with InfoZip and that seemed to recreate the directory structure as well.

I am not sure if it is quite true that "most" windows software
supports bz2 or gz yet. However, it is true that it is becoming easier
to find tools that do (like 7-zip or the recently released Winzip 12).

Personally, I use bz2 for our production environment backup.

The revised patch is attached and here is the revised patch log message:

[[[
In the hot-backup.py script, also add empty directories to a Zip backup
(when using option --archive-type=zip). Implements this suggestion:
http://mail.python.org/pipermail/python-list/2004-June/266067.html

Patch by: eg <eg...@gmail.com>

* tools/backup/hot-backup.py.in (add_to_zip): Add empty directories to
      Zip files by explicitly writing the directory names with a trailing
      slash. Empty directories were previously omitted in Zip files.
]]]



Re: [PATCH] Fix hot-backup.py issue where zip archives do not backup empty directories

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Ping?  Neels, you said planned to commit this one?

Daniel



eg wrote on Mon, 27 Oct 2008 at 23:16 -0700:
> Neels J. Hofmeyr wrote:
> 
> > 
> > I took a look at the python documentation, and it says this:
> > 
> > [[[
> > [ZipFile.]writestr( zinfo_or_arcname, bytes)
> >     Write the string bytes to the archive; zinfo_or_arcname is either the
> > file name it will be given in the archive, or a ZipInfo instance. If it's an
> > instance, at least the filename, date, and time must be given. If it's a
> > name, the date and time is set to the current date and time. The archive
> > must be opened with mode 'w' or 'a'.
> > ]]]
> > 
> > Have you paid attention to the date and time stuff?
> > 
> > When I test your patch on GNU/Linux, empty directories are added with a date
> > of 1980-01-01 00:00, which is not what the writestr() documentation says (if
> > I understand that correctly).
> 
> hmmm... I must have mixed up reading the zinfo vs filename
> initialization logic in the help string. In the zinfo case, giving no
> time/date initializes it to 0 time which corresponds to the 1980-01-01
> date/time. Not what the function needs nor what we want.
> 
> > 
> > Could you please investigate? We're close to a commit, but the date/time
> > thing would be nice to clarify: Either fix it, or find a good reason why
> > it's not needed.
> 
> 
> I have fixed it in the attached patch.
> 
> 
> > I'll commit as soon as the date/time thing is reviewed/resolved.
> 
> Thanks for your help and patience on this.
> 
> > 
> > For the record: while my `unzip' commandline tool successfully creates the
> > empty directories as above, the Gnome Archive Manager fails to list them (so
> > it's kind of a special case). I'd encourage using bz2 or gz instead. Most MS
> > Windows software supports these archive types, so there's really no need to
> > use zip archives in the first place (right?).
> > 
> 
> I did my testing with both 7-zip and winzip under WindowsXp and they
> both re-create the directories correctly too. I also did a quick test with
> InfoZip and that seemed to recreate the directory structure as well.
> 
> I am not sure if it is quite true that "most" windows software
> supports bz2 or gz yet. However, it is true that it is becoming easier
> to find tools that do (like 7-zip or the recently released Winzip 12).
> 
> Personally, I use bz2 for our production environment backup.
> 
> The revised patch is attached and here is the revised patch log message:
> 
> [[[
> In the hot-backup.py script, also add empty directories to a Zip backup
> (when using option --archive-type=zip). Implements this suggestion:
> http://mail.python.org/pipermail/python-list/2004-June/266067.html
> 
> Patch by: eg <eg...@gmail.com>
> 
> * tools/backup/hot-backup.py.in (add_to_zip): Add empty directories to
>      Zip files by explicitly writing the directory names with a trailing
>      slash. Empty directories were previously omitted in Zip files.
> ]]]
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org