Description
After an upgrade to 1.8.2, attaching a file (32KB .odt) the wiki returns an error:
BadZipfile
Bad magic number for central directory
* args = ('Bad magic number for central directory',)Attachments for that page can no longer be viewed. Checking the filesystem shows the attachment was uploaded successfully. Deleting the attachment via the filesystem restores the attachment view function.
Steps to reproduce
- Upload an attachment to Moin 1.8.2
Example
Component selection
action: AttachFile.py
Details
HTML traceback page attached: moinbugBadZipfile.tar.gz
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/MoinMoin/request/__init__.py", line 1311, in run
handler(self.page.page_name, self)
File "/usr/lib/python2.4/site-packages/MoinMoin/action/AttachFile.py", line 513, in execute
msg = handler(pagename, request)
File "/usr/lib/python2.4/site-packages/MoinMoin/action/AttachFile.py", line 601, in _do_upload
upload_form(pagename, request, msg)
File "/usr/lib/python2.4/site-packages/MoinMoin/action/AttachFile.py", line 533, in upload_form
send_uploadform(pagename, request)
File "/usr/lib/python2.4/site-packages/MoinMoin/action/AttachFile.py", line 493, in send_uploadform
request.write(_get_filelist(request, pagename))
File "/usr/lib/python2.4/site-packages/MoinMoin/action/AttachFile.py", line 386, in _get_filelist
return _build_filelist(request, pagename, 1, 0)
File "/usr/lib/python2.4/site-packages/MoinMoin/action/AttachFile.py", line 337, in _build_filelist
is_package = packages.ZipPackage(request, fullpath).isPackage()
File "/usr/lib/python2.4/site-packages/MoinMoin/packages.py", line 486, in __init__
self.zipfile = zipfile.ZipFile(filename)
File "zipfile.py", line 210, in __init__
self._GetContents()
File "zipfile.py", line 230, in _GetContents
self._RealGetContents()
File "zipfile.py", line 262, in _RealGetContents
raise BadZipfile, "Bad magic number for central directory"
BadZipfile: Bad magic number for central directoryMoinMoin Version |
1.8.2 |
OS and Version |
Debian 4.0 etch |
Python Version |
2.4.4 |
Server Setup |
debian etch, apache2, libapache2-mod-wsgi, moinmoin 1.8.2 |
Server Details |
web server |
Language you are using the wiki in (set in the browser/UserPreferences) |
English |
Workaround
Discussion
I found this reference to a python zipfile bug that may be related: http://bugs.python.org/issue3997, but I'm not uploading zip files.
Made a test testdocument.odt and could not reproduce this error on this server. maybe your mimetype config on the server says that odt are zip files and that's why moinmoin tries to unpack it (sure the error message is not nice, this "unzip" should be more fault tolerant and display just a nice message)... -- MarcelHäfner 2009-04-22 06:51:11
please can you tell what you get for
>:/etc > grep odt mime.types
it should be
application/vnd.oasis.opendocument.text odt
Likly no bug. Please check if you have a recent MoinMoin/wikiutil.py. You should have in line 841: '.odt': 'application/vnd.oasis.opendocument.text', This means we do already extend the mimetype mapping.
Do you have used the --force parameter for your update installation. Was the old py cache code *.pyc file removed?
- Hi all and thanks for looking at this. The mime.type is as expected:
service:/etc# grep odt mime.types application/vnd.oasis.opendocument.text odt service:/etc#
wikiutil.py shows this:
service:~# grep -n odt /usr/lib/python2.4/site-packages/MoinMoin/wikiutil.py 919: '.odt': 'application/vnd.oasis.opendocument.text', service:~# ls -l /usr/lib/python2.4/site-packages/MoinMoin/wikiutil.py* -rw-r--r-- 1 root root 90056 2009-02-08 05:25 /usr/lib/python2.4/site-packages/MoinMoin/wikiutil.py -rw-r--r-- 1 root root 80796 2009-04-20 22:17 /usr/lib/python2.4/site-packages/MoinMoin/wikiutil.pyc service:~#
The problem appears to be local to that page, in that on other pages I can upload attachments and they are displayed correctly in the attachment view without the BadZipfile error. Also the SystemAdmin macro attachment viewer has no issue. I've ensured the permissions and ownership of that page and subfolders is the same as any other Page (owned by www-data and rw). To clarify, the attachment is uploaded ok, despite the badzipfile error message. I can also refer to it with an attachment: link and download it from the attachment page. It is just the attachment list view that causes the error on this page.
I'll outline my install/upgrade procedure in case I've missed something:
moin 1.7.2# python -v setup.py install --record=/root/moininstall.log moin 1.7.2# ../createinstance.sh /srv/var/moin/hcwiki config moin config apache backup INSTANCE/data mv INSTANCE INSTANCE.bak moin 1.8.2# for i in `cat /root/moininstall.log` ; do rm $i ; done moin 1.8.2# python -v setup.py install --record=/root/moininstall.log moin 1.8.2# ../createinstance.sh /srv/var/moin/hcwiki restore edit-log event-log data/pages data/users to $INSTANCE # su - www-data www-data$ moin --config-dir=/etc/moin/hcwiki --wiki-url=service.harmsconsulting.com/hcwiki migration data www-data$ moin --config-dir=/etc/moin/hcwiki --wiki-url=service.harmsconsulting.com/hcwiki maint cleancache config moin config apache
Is that sufficient to replace the old installation? I can't find any reference to the --force parameter (presumably to setup.py) - I looked in BasicInstallation and grep force setup.py. Cheers and regards, -- HarmsCon 2009-04-23 00:55:57
Do you have stopped the wiki server process at the time you cleaned the cache?
Do you use custom macros for your attachment list. The standard macros work, see here;
There are 4 attachment(s) stored for this page.
- [get | view] (2009-04-22 04:36:32, 21.6 KB) [[attachment:moinbugBadZipfile.tar.gz]]
- [get | view] (2009-04-24 19:55:06, 40.6 KB) [[attachment:test.odt]]
- [get | view] (2009-04-22 06:44:37, 8.6 KB) [[attachment:testdocument.odt]]
- [get | view] (2009-04-22 04:34:21, 75.4 KB) [[attachment:wiki-error.png]]
Please check whether you can unpack that odt file triggering the problem with unzip command. Also check whether you can load that file with openoffice. If you succeed with both, please attach the file here so we can reproduce the problem.
Thomas, you are a legend! I never realised odt files were zipped, and trying to unzip it as suggested resulted in the start of central directory not found error message. I repaired the doc and re-uploaded it with a clean result. Thanks to you all for your time, josh. -- HarmsCon 2009-04-27 01:05:52
OK, good that we have found the problem being in the document.
But anyway: moin should not completely fall over such a problem, but catch it somehow. This is why we still need some defective zip file to reproduce the problem. I am leaving the bug open for fixing the exception handler to deal with such stuff nicely.
Plan
- Priority:
- Assigned to:
- Status: need corrupt zip file to fix exception handler
