support allocating storage in client_test
This commit is contained in:
@@ -501,7 +501,7 @@ typedef std::multimap<std::string, libtorrent::torrent_handle> handles_t;
|
|||||||
|
|
||||||
int listen_port = 6881;
|
int listen_port = 6881;
|
||||||
float preferred_ratio = 0.f;
|
float preferred_ratio = 0.f;
|
||||||
std::string allocation_mode = "sparse";
|
int allocation_mode = libtorrent::storage_mode_sparse;
|
||||||
std::string save_path(".");
|
std::string save_path(".");
|
||||||
int torrent_upload_limit = 0;
|
int torrent_upload_limit = 0;
|
||||||
int torrent_download_limit = 0;
|
int torrent_download_limit = 0;
|
||||||
@@ -520,7 +520,7 @@ void add_torrent(libtorrent::session& ses
|
|||||||
, handles_t& handles
|
, handles_t& handles
|
||||||
, std::string const& torrent
|
, std::string const& torrent
|
||||||
, float preferred_ratio
|
, float preferred_ratio
|
||||||
, bool compact_mode
|
, int allocation_mode
|
||||||
, std::string const& save_path
|
, std::string const& save_path
|
||||||
, bool monitored_dir
|
, bool monitored_dir
|
||||||
, int torrent_upload_limit
|
, int torrent_upload_limit
|
||||||
@@ -550,7 +550,7 @@ void add_torrent(libtorrent::session& ses
|
|||||||
|
|
||||||
p.ti = t;
|
p.ti = t;
|
||||||
p.save_path = save_path;
|
p.save_path = save_path;
|
||||||
p.storage_mode = compact_mode ? storage_mode_compact : storage_mode_sparse;
|
p.storage_mode = (storage_mode_t)allocation_mode;
|
||||||
p.paused = true;
|
p.paused = true;
|
||||||
p.duplicate_is_error = false;
|
p.duplicate_is_error = false;
|
||||||
p.auto_managed = true;
|
p.auto_managed = true;
|
||||||
@@ -573,7 +573,7 @@ void scan_dir(std::string const& dir_path
|
|||||||
, libtorrent::session& ses
|
, libtorrent::session& ses
|
||||||
, handles_t& handles
|
, handles_t& handles
|
||||||
, float preferred_ratio
|
, float preferred_ratio
|
||||||
, bool compact_mode
|
, int allocation_mode
|
||||||
, std::string const& save_path
|
, std::string const& save_path
|
||||||
, int torrent_upload_limit
|
, int torrent_upload_limit
|
||||||
, int torrent_download_limit)
|
, int torrent_download_limit)
|
||||||
@@ -597,7 +597,7 @@ void scan_dir(std::string const& dir_path
|
|||||||
|
|
||||||
// the file has been added to the dir, start
|
// the file has been added to the dir, start
|
||||||
// downloading it.
|
// downloading it.
|
||||||
add_torrent(ses, handles, file, preferred_ratio, compact_mode
|
add_torrent(ses, handles, file, preferred_ratio, allocation_mode
|
||||||
, save_path, true, torrent_upload_limit, torrent_download_limit);
|
, save_path, true, torrent_upload_limit, torrent_download_limit);
|
||||||
valid.insert(file);
|
valid.insert(file);
|
||||||
}
|
}
|
||||||
@@ -838,8 +838,7 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
add_torrent_params p;
|
add_torrent_params p;
|
||||||
p.save_path = save_path;
|
p.save_path = save_path;
|
||||||
p.storage_mode = allocation_mode == "compact" ? storage_mode_compact
|
p.storage_mode = (storage_mode_t)allocation_mode;
|
||||||
: storage_mode_sparse;
|
|
||||||
printf("adding MANGET link: %s\n", argv[i]);
|
printf("adding MANGET link: %s\n", argv[i]);
|
||||||
error_code ec;
|
error_code ec;
|
||||||
torrent_handle h = add_magnet_uri(ses, argv[i], p, ec);
|
torrent_handle h = add_magnet_uri(ses, argv[i], p, ec);
|
||||||
@@ -871,8 +870,7 @@ int main(int argc, char* argv[])
|
|||||||
p.tracker_url = argv[i] + 41;
|
p.tracker_url = argv[i] + 41;
|
||||||
p.info_hash = info_hash;
|
p.info_hash = info_hash;
|
||||||
p.save_path = save_path;
|
p.save_path = save_path;
|
||||||
p.storage_mode = allocation_mode == "compact" ? storage_mode_compact
|
p.storage_mode = (storage_mode_t)allocation_mode;
|
||||||
: storage_mode_sparse;
|
|
||||||
p.paused = true;
|
p.paused = true;
|
||||||
p.duplicate_is_error = false;
|
p.duplicate_is_error = false;
|
||||||
p.auto_managed = true;
|
p.auto_managed = true;
|
||||||
@@ -896,7 +894,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
// if it's a torrent file, open it as usual
|
// if it's a torrent file, open it as usual
|
||||||
add_torrent(ses, handles, argv[i], preferred_ratio
|
add_torrent(ses, handles, argv[i], preferred_ratio
|
||||||
, allocation_mode == "compact", save_path, false
|
, allocation_mode, save_path, false
|
||||||
, torrent_upload_limit, torrent_download_limit);
|
, torrent_upload_limit, torrent_download_limit);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -918,7 +916,10 @@ int main(int argc, char* argv[])
|
|||||||
case 'd': ses.set_download_rate_limit(atoi(arg) * 1000); break;
|
case 'd': ses.set_download_rate_limit(atoi(arg) * 1000); break;
|
||||||
case 'u': ses.set_upload_rate_limit(atoi(arg) * 1000); break;
|
case 'u': ses.set_upload_rate_limit(atoi(arg) * 1000); break;
|
||||||
case 'S': ses.set_max_uploads(atoi(arg)); break;
|
case 'S': ses.set_max_uploads(atoi(arg)); break;
|
||||||
case 'a': allocation_mode = arg; break;
|
case 'a':
|
||||||
|
if (strcmp(arg, "allocate") == 0) allocation_mode = storage_mode_allocate;
|
||||||
|
if (strcmp(arg, "compact") == 0) allocation_mode = storage_mode_compact;
|
||||||
|
break;
|
||||||
case 's': save_path = arg; break;
|
case 's': save_path = arg; break;
|
||||||
case 'U': torrent_upload_limit = atoi(arg) * 1000; break;
|
case 'U': torrent_upload_limit = atoi(arg) * 1000; break;
|
||||||
case 'D': torrent_download_limit = atoi(arg) * 1000; break;
|
case 'D': torrent_download_limit = atoi(arg) * 1000; break;
|
||||||
@@ -1610,7 +1611,7 @@ int main(int argc, char* argv[])
|
|||||||
&& next_dir_scan < time_now())
|
&& next_dir_scan < time_now())
|
||||||
{
|
{
|
||||||
scan_dir(monitor_dir, ses, handles, preferred_ratio
|
scan_dir(monitor_dir, ses, handles, preferred_ratio
|
||||||
, allocation_mode == "compact", save_path, torrent_upload_limit
|
, allocation_mode, save_path, torrent_upload_limit
|
||||||
, torrent_download_limit);
|
, torrent_download_limit);
|
||||||
next_dir_scan = time_now() + seconds(poll_interval);
|
next_dir_scan = time_now() + seconds(poll_interval);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user