#3903 closed defect (fixed)
Binary files got currupted when viewing via TracMercurial plugin
Reported by: | anonymous | Owned by: | Christian Boos |
---|---|---|---|
Priority: | high | Milestone: | not applicable |
Component: | plugin/mercurial | Version: | 0.10 |
Severity: | normal | Keywords: | mercurial |
Cc: | asl@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
I have Trac 0.10 installed among with TracMercurial plugin. Repository browsing works fine for text files, but doesn't for binary files. E.g. I have some images in the repository. Browser shows correct size for them, but downloaded file differs in size. Even more, only first 0x1000 bytes are valid. Others are just the first 0x1000 bytes iterating until the file ends.
Attachments (0)
Change History (6)
comment:1 by , 18 years ago
Keywords: | mercurial added |
---|---|
Priority: | normal → high |
Status: | new → assigned |
comment:2 by , 18 years ago
Thank you for fast respond! Everything works fine, but, please note, that "self.data" should be returned at line 345, not just "data".
comment:3 by , 18 years ago
Well, another check showed, that text files appeared as binary after the patch: it says something like "HTML preview not available".
Sometimes (in really random fashion) it displays html-formatted text, but only the last "chunk".
comment:4 by , 18 years ago
It seems, I've tracked down the problem.
- Everything works ok for "text" or "raw" format
- versioncontrol/web_ui/browser.py uses get_content() to pass file contents to renderer. get_content() call just returns the "self". But at the moment of get_content() call 1 chunk is already read (to detect mime type), thus self.pos is already set to CHUNK_SIZE. Surely, renderer gets just part of the file (or nothing at all). This patch works for me (I don't know, whether it's correct or not):
--- backend.py 2006-10-11 17:28:57.000000000 +0400 +++ backend.py 2006-10-11 17:30:56.540676287 +0400 @@ -328,8 +328,9 @@ def get_content(self): if self.isdir: return None - self.pos = 0 - return self # something that can be `read()` ... + obj = self + obj.pos = 0 + return obj # something that can be `read()` ... def read(self, size=None): if self.isdir:
comment:5 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Ha, at the same time I committed r3894, with a similar fix. Thanks for the feedback!
comment:6 by , 16 years ago
Component: | version control → plugin/mercurial |
---|---|
Milestone: | → not applicable |
Can you please try the following patch?