castget icon indicating copy to clipboard operation
castget copied to clipboard

Error "Failed writing body"

Open mschaeuble opened this issue 8 years ago • 9 comments

With some feeds (e.g. http://www.srf.ch/feed/podcast/hd/3b016ffc-afa2-466d-a694-c48b7ffe1783.xml), I get an error of the form "Failed writing body" when downloading the enclosures:

Error retrieving http://podcastsource.sf.tv/nps/-1706219814/5740.16/Inside+Bundeshaus+%E2%80%93+Ein+Volksentscheid+und+seine+Folgen/podcast/dok/2017/02/dok_20170209_200811_v_podcast_h264_q30.mp4: Failed writing body (116 != 1448)
Error downloading enclosure from http://podcastsource.sf.tv/nps/-1706219814/5740.16/Inside+Bundeshaus+%E2%80%93+Ein+Volksentscheid+und+seine+Folgen/podcast/dok/2017/02/dok_20170209_200811_v_podcast_h264_q30.mp4.

mschaeuble avatar Feb 16 '17 20:02 mschaeuble

Thanks for reporting this. The RSS feed has a bizarre length attribute for the enclosure (probably an overflow when it was generated), and this confuses castget.

<enclosure type="video/mp4" length="-1706219814" url="http://podcastsource.sf.tv/nps/-1706219814/5740.16/Inside+Bundeshaus+%E2%80%93+Ein+Volksentscheid+und+seine+Folgen/podcast/dok/2017/02/dok_20170209_200811_v_podcast_h264_q30.mp4"/>

This will be fixed in the next minor version.

mlj avatar Mar 01 '17 09:03 mlj

Cool, looking forward for the next minor version :-)

mschaeuble avatar Mar 03 '17 19:03 mschaeuble

Any plans when this is going to be fixed? This bug is really annoying.

mschaeuble avatar May 01 '17 10:05 mschaeuble

Looking at this again I don't think the overflow in the length attribute is the issue. These all download without problem for me with or without the fix.

Are you sure you're not simply running out of disk space? These are large files... You may also be hitting a filesystem limit. The files we're talking about here will all be larger than 2GB.

mlj avatar May 04 '17 11:05 mlj

Disc space is not an issue. Filesystem used is ext4 and I'm able to download the files manually using wget, but it doesn't work castget.

mschaeuble avatar May 04 '17 20:05 mschaeuble

Can you test castget with the two previous patches applied? The last one extends the error message so that it includes the error message from the failed libc call.

mlj avatar May 04 '17 21:05 mlj

Output from castget with the two patches applied:

Updating channel Einstein...

  • Downloading einstein_20170504_200818_5361587_v_podcast_h264_q30.mp4 (unknown length) from Einstein HD ########################################################################## 100%Error retrieving http://podcastsource.sf.tv/nps/-1762137687/5599.0/%C2%ABEinstein%C2%BB+auf+Kreuzfahrt/podcast/einstein/2017/05/einstein_20170504_200818_5361587_v_podcast_h264_q30.mp4: Failed writing body (2556 != 6784): File too large

Error downloading enclosure from http://podcastsource.sf.tv/nps/-1762137687/5599.0/%C2%ABEinstein%C2%BB+auf+Kreuzfahrt/podcast/einstein/2017/05/einstein_20170504_200818_5361587_v_podcast_h264_q30.mp4.

Additionally, I figured out that this issue only happens on a machine with ARM architecture (Raspberry PI), the same version on a X86 machine works perfectly well! Any ideas?

mschaeuble avatar May 07 '17 18:05 mschaeuble

This issue seems to be related to a 2 gb limit: The (incomplete) file written has a size of exactly 2048 mb.

A probably related question on stackoverflow: http://stackoverflow.com/questions/730709/2gb-limit-on-file-size-when-using-fwrite-in-c

mschaeuble avatar May 07 '17 19:05 mschaeuble

Great, thanks for testing this!

I'll have to experiment a bit with -D_FILE_OFFSET_BITS=64 etc. before committing this, but at least now we know what the issue is.

If you want a quick fix, it may work to recompile castget (with or without the above patches) like this:

CFLAGS=-D_FILE_OFFSET_BITS=64 ./configure && make

(remember a make clean first if you're compiling from an existing copy).

mlj avatar May 07 '17 19:05 mlj