After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 345941 - data-io opens files in wrong mode
data-io opens files in wrong mode
Status: RESOLVED FIXED
Product: Pan
Classification: Other
Component: general
pre-1.0 betas
Other Windows
: Normal critical
: 1.0
Assigned To: Charles Kerr
Pan QA Team
: 345787 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-06-26 08:12 UTC by Kenneth Haley
Modified: 2006-06-30 20:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
simple patch to open datafiles in binary mode and to log an error on failure (590 bytes, patch)
2006-06-27 15:41 UTC, Charles Kerr
none Details | Review
another can't-write-file error notification, this time in article-cache::add (528 bytes, patch)
2006-06-27 15:47 UTC, Charles Kerr
none Details | Review

Description Kenneth Haley 2006-06-26 08:12:30 UTC
The function get_ostream in data-io.cc opens the stream in the wrong mode on windows.  Streams are in text mode by default on windows.  Since FileReader is opening files in binary mode this results in \r being added onto retreived data.  Because of this the article cache was not able to create any files, nor could it open any existing files.

Here is the simple fix for get_ostream:

std::ofstream * o (new std::ofstream (tmp.c_str(), std::ios_base::out|std::ios_base::binary));

Also, on a diagnostic issue, ArticleCache::add should output a debug message if fp==0.  The "Unable to save" message could be re-used here.
Comment 1 Charles Kerr 2006-06-26 15:29:06 UTC
I'm sure that none of Pan's data files are binary anymore.
Would it make more sense to just use text mode throughout?
Comment 2 Kenneth Haley 2006-06-26 23:35:06 UTC
I think it's easier to stick with binary.  At least that way when someone tries to use their pan data on multiple os's it should just work.  At least I think I remember someone dual booting windows & linux wanting to use pan on both.
Comment 3 Charles Kerr 2006-06-27 15:41:23 UTC
Created attachment 68076 [details] [review]
simple patch to open datafiles in binary mode and to log an error on failure
Comment 4 Charles Kerr 2006-06-27 15:47:39 UTC
Created attachment 68078 [details] [review]
another can't-write-file error notification, this time in article-cache::add
Comment 5 Charles Kerr 2006-06-27 15:50:28 UTC
I'm wondering if this is actually the cause of the problem you're seeing.
article-cache doesn't use the data-io ostream code -- it saves messages 
via fopen "wb" and reads them via fopen "rb" or g_file_get_contents.
Comment 6 Charles Kerr 2006-06-27 22:12:24 UTC
*** Bug 345787 has been marked as a duplicate of this bug. ***
Comment 7 Kenneth Haley 2006-06-28 02:56:08 UTC
The problem was that the messasge id's would have \r characters at the end.  When data-io wrote the group files in text mode they had \r\n line endings.  Then LineReader would read in binary mode looking for \n as the end leaving the \r in the message id and probably other lines as well.  Of course each time the group file was saved another \r would be added.  I could see those characters in gdb.  Since filenames can't have \r, the cache could not create the file.  It also prevented matching articles that were already in the cache since their message ids didn't have the extra characters.
Comment 8 Charles Kerr 2006-06-28 05:22:53 UTC
Ah, that makes perfect sense.