From 7410b279902766bc632cc4c03c5091d37702dfb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Cabaniols?= Date: Tue, 12 Jul 2016 09:58:56 +0200 Subject: [PATCH 1/4] allow seconds for seed-time (fractional minutes) --- src/BtSetup.cc | 2 +- src/OptionHandlerFactory.cc | 2 +- src/prefs.h | 2 +- src/usage_text.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/BtSetup.cc b/src/BtSetup.cc index e541fd7e..d74fe41c 100644 --- a/src/BtSetup.cc +++ b/src/BtSetup.cc @@ -158,7 +158,7 @@ void BtSetup::setup(std::vector>& commands, auto unionCri = make_unique(); if (option->defined(PREF_SEED_TIME)) { unionCri->addSeedCriteria(make_unique( - std::chrono::seconds(option->getAsInt(PREF_SEED_TIME) * 60))); + std::chrono::seconds((int)(option->getAsDouble(PREF_SEED_TIME) * 60)))); } { double ratio = option->getAsDouble(PREF_SEED_RATIO); diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index 595f9cd9..9d5a9489 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -1799,7 +1799,7 @@ std::vector OptionHandlerFactory::createOptionHandlers() handlers.push_back(op); } { - OptionHandler* op(new NumberOptionHandler(PREF_SEED_TIME, TEXT_SEED_TIME, + OptionHandler* op(new FloatNumberOptionHandler(PREF_SEED_TIME, TEXT_SEED_TIME, NO_DEFAULT_VALUE, 0)); op->addTag(TAG_BITTORRENT); op->setInitialOption(true); diff --git a/src/prefs.h b/src/prefs.h index 68eb408f..9188f656 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -420,7 +420,7 @@ extern PrefPtr PREF_LISTEN_PORT; extern PrefPtr PREF_FOLLOW_TORRENT; // values: 1*digit *( (,|-) 1*digit) extern PrefPtr PREF_SELECT_FILE; -// values: 1*digit +// values: 1*digit ['.' [ 1*digit ] ] extern PrefPtr PREF_SEED_TIME; // values: 1*digit ['.' [ 1*digit ] ] extern PrefPtr PREF_SEED_RATIO; diff --git a/src/usage_text.h b/src/usage_text.h index 6c30f84a..7ab6a7ff 100644 --- a/src/usage_text.h +++ b/src/usage_text.h @@ -313,7 +313,7 @@ " To limit the overall upload speed, use\n" \ " --max-overall-upload-limit option.") #define TEXT_SEED_TIME \ - _(" --seed-time=MINUTES Specify seeding time in minutes. Also see the\n" \ + _(" --seed-time=MINUTES Specify seeding time in (fractional) minutes. Also see the\n" \ " --seed-ratio option.") #define TEXT_SEED_RATIO \ _(" --seed-ratio=RATIO Specify share ratio. Seed completed torrents\n" \ From 196f8c4ad9ddb8b80389c58e37d205eaab980177 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 18 Jul 2016 17:38:52 +0900 Subject: [PATCH 2/4] Fix help output --- src/usage_text.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/usage_text.h b/src/usage_text.h index 7ab6a7ff..43ad21c0 100644 --- a/src/usage_text.h +++ b/src/usage_text.h @@ -313,8 +313,8 @@ " To limit the overall upload speed, use\n" \ " --max-overall-upload-limit option.") #define TEXT_SEED_TIME \ - _(" --seed-time=MINUTES Specify seeding time in (fractional) minutes. Also see the\n" \ - " --seed-ratio option.") + _(" --seed-time=MINUTES Specify seeding time in (fractional) minutes.\n" \ + " Also see the --seed-ratio option.") #define TEXT_SEED_RATIO \ _(" --seed-ratio=RATIO Specify share ratio. Seed completed torrents\n" \ " until share ratio reaches RATIO.\n" \ From 196e4cbedef4caaf458c45312fc0cac255cee5da Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 18 Jul 2016 17:41:09 +0900 Subject: [PATCH 3/4] Use C++ style cast --- src/BtSetup.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/BtSetup.cc b/src/BtSetup.cc index d74fe41c..63f20569 100644 --- a/src/BtSetup.cc +++ b/src/BtSetup.cc @@ -157,8 +157,9 @@ void BtSetup::setup(std::vector>& commands, if (!metadataGetMode) { auto unionCri = make_unique(); if (option->defined(PREF_SEED_TIME)) { - unionCri->addSeedCriteria(make_unique( - std::chrono::seconds((int)(option->getAsDouble(PREF_SEED_TIME) * 60)))); + unionCri->addSeedCriteria( + make_unique(std::chrono::seconds( + static_cast(option->getAsDouble(PREF_SEED_TIME) * 60)))); } { double ratio = option->getAsDouble(PREF_SEED_RATIO); From 66976ea4b1a1cf01669bfa1d5f57fc19456bb78a Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 18 Jul 2016 17:41:56 +0900 Subject: [PATCH 4/4] Update doc --- doc/manual-src/en/aria2c.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/manual-src/en/aria2c.rst b/doc/manual-src/en/aria2c.rst index 0086ac51..83182860 100644 --- a/doc/manual-src/en/aria2c.rst +++ b/doc/manual-src/en/aria2c.rst @@ -939,7 +939,8 @@ BitTorrent Specific Options .. option:: --seed-time= - Specify seeding time in minutes. Also see the :option:`--seed-ratio` option. + Specify seeding time in (fractional) minutes. Also see the + :option:`--seed-ratio` option. .. note::