torrent_client 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03d06ee01d006e8d24a119e266b2aaf08f4d7b64
4
- data.tar.gz: 71da685aebeea8cfa4b1f29d62d6ea071c4fa6c3
3
+ metadata.gz: 77f3beb70a73972a925aaaa1b84fc400eb3e44df
4
+ data.tar.gz: 59b3fedbedbda0d258776a3108e89e1e8da0c208
5
5
  SHA512:
6
- metadata.gz: f5bdbb04d6fb3fe9ecd5429a114b70378443cc6a7f5d3925b6c7fd7d0bcdae5a803a2f0e1e308931667314e271feed68250d5fbeeca72b9fe71c3b99085ebbf0
7
- data.tar.gz: 85e7c24edc7c27b66c5822a88e9dc060f03f25df28f53efd71708d14e2267fcc9ef64b10f6424915ab7bf609e87e08f34533b3a12adbaeabbd748edccddb97ec
6
+ metadata.gz: 558e6b34501da7960c0982816c2d72c687d006508134ec2a18ca7badda3ae0a2404a45e312a2dafe78455d141f78d6694fc0d56f9976b18dbaa454952533690b
7
+ data.tar.gz: b1d8a7d96f6860d5e24a4373d28a2abf0e11944ac91b28a18afe016a06bdffcabc6733085023c1ea45f12b5369837f577c7e09fda85856cc991d596d415a66d2
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.1] - 2016-04-06
4
+
5
+ Fixes TorrentClient.verify, which wasn't returning false when the file was
6
+ corrupted. Also should be more robust to halting on errors.
7
+
3
8
  ## [0.2.0] - 2016-04-06
4
9
 
5
10
  Adds TorrentClient.verify, moves libtorrent session creation to happen once when
@@ -53,7 +53,7 @@ extern "C" {
53
53
  return Qnil;
54
54
  }
55
55
 
56
- while (true) {
56
+ while (handle.is_valid()) {
57
57
  if (_session->wait_for_alert(lt::seconds(1))) {
58
58
  std::auto_ptr<lt::alert> a = _session->pop_alert();
59
59
  if (a->type() == lt::torrent_finished_alert::alert_type) {
@@ -75,7 +75,6 @@ extern "C" {
75
75
  lt::error_code ec;
76
76
  lt::add_torrent_params p;
77
77
  p.save_path = StringValueCStr(destination_dir);
78
- p.flags = lt::add_torrent_params::flag_paused;
79
78
  p.ti = new lt::torrent_info(StringValueCStr(torrent_file), ec);
80
79
  if (ec) {
81
80
  rb_raise(rb_eRuntimeError, ec.message().c_str());
@@ -88,21 +87,22 @@ extern "C" {
88
87
  return Qnil;
89
88
  }
90
89
 
91
- lt::torrent_status status = handle.status();
92
- while (status.state == lt::torrent_status::checking_files ||
93
- status.state == lt::torrent_status::checking_resume_data) {
94
- _session->wait_for_alert(lt::seconds(1));
95
- status = handle.status();
90
+ bool success = false;
91
+ bool running = true;
92
+ while (handle.is_valid()) {
93
+ if (_session->wait_for_alert(lt::seconds(1))) {
94
+ std::auto_ptr<lt::alert> a = _session->pop_alert();
95
+ if (a->type() == lt::torrent_checked_alert::alert_type) {
96
+ handle.pause();
97
+ success = handle.status(0).is_finished;
98
+ break;
99
+ }
100
+ }
96
101
  }
97
102
 
98
103
  _session->remove_torrent(handle);
99
104
 
100
- if (status.state == lt::torrent_status::seeding ||
101
- status.state == lt::torrent_status::queued_for_checking) {
102
- return Qtrue;
103
- } else {
104
- return Qfalse;
105
- }
105
+ return success ? Qtrue : Qfalse;
106
106
  } catch (std::exception &e) {
107
107
  rb_raise(rb_eRuntimeError, "failed from unknown exception");
108
108
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torrent_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Smith