y500 / libtorrent

Automatically exported from code.google.com/p/libtorrent
0 stars 0 forks source link

pre-allocation to a network share does not work properly #629

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.Start a download to a network share (In this case to an SMB 3.0 share on a 
windows server 2012 R2)
2.Libtorrent starts a standard allocation process and starts to write the file 
over the link which takes a very long time on slower links.

What is the expected output? What do you see instead?
Libtorrent should properly do a sparse allocation operation to a network share 
instead of a standard write-allocation.

What version of the product are you using? On what operating system?
0.16.16+svn9872 with qbittorrent wrapper on windows 8.1

Please provide any additional information below.
I have not tested with nfs shares but likely same problem persists with that as 
well.

Original issue reported on code.google.com by Zapo...@gmail.com on 6 Jun 2014 at 5:29

GoogleCodeExporter commented 8 years ago
does this patch work and make sense? (it's against trunk)

Index: src/storage.cpp
===================================================================
--- src/storage.cpp       (revision 9985)
+++ src/storage.cpp       (working copy)
@@ -405,6 +405,14 @@
   bool default_storage::initialize(bool allocate_files)
   {
           m_allocate_files = allocate_files;
+
+#ifdef TORRENT_WINDOWS
+         // don't do full file allocations on network drives
+         int drive_type = GetDriveType(m_save_path.c_str());
+         if (drive_type == DRIVE_REMOTE)
+                 m_allocate_files = false;
+#endif
+
           error_code ec;
           m_file_created.resize(files().num_files(), false);

Original comment by arvid.no...@gmail.com on 6 Jun 2014 at 3:57

GoogleCodeExporter commented 8 years ago
I committed this to trunk. please re-open this ticket if you find any issues.

Original comment by arvid.no...@gmail.com on 7 Jun 2014 at 4:19