Ticket #1580 (new defect)
rtorrent creates and resizes all files when first starting download
| Reported by: | anonymous | Owned by: | rakshasa |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | libtorrent | Version: | |
| Severity: | normal | Keywords: | |
| Cc: |
Description
While rtorrent 0.8.4 is advertised to only resize those files that it should download (of course including adjacent files in the same chunks), it always creates all files AND sets their filesize.
On filesystems with no support for sparse files (HFS+, VFAT, etc.) this means they occupy diskspace even though they're not wanted.
I've tracked down the problem and fixed it like this:
Index: libtorrent/src/torrent/data/file_list.cc
===================================================================
--- libtorrent/src/torrent/data/file_list.cc (revision 1087)
+++ libtorrent/src/torrent/data/file_list.cc (working copy)
@@ -544,7 +544,6 @@
}
return
- node->prepare(MemoryChunk::prot_read | MemoryChunk::prot_write, (flags & open_no_create ? 0 : SocketFile::o_create)) ||
node->prepare(MemoryChunk::prot_read, 0);
}
Basically, when opening the filelist, it ALWAYS tries to map a writable chunk. This ALWAYS calls ftruncate on the file. Even when we don't even want the file at all.
Removing that one line fixed the problem, now files are only resized when something is downloaded. I believe this is the intended behaviour, but I'm not sure that my fix doesn't break something else, other than not checking if the files would be writable, a problem which would later cause a storage error which I think is fine.
Please advise.
