Skip to content

Commit

Permalink
Moved the source string to the info hash, as it should be
Browse files Browse the repository at this point in the history
  • Loading branch information
fuchsi committed May 27, 2019
1 parent f83b3d3 commit 697606f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [0.2.1] - 27.05.2019

### Fixed
- Moved the source string to the info hash, as it should be

## [0.2.0] - 27.05.2019

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "maketorrent"
version = "0.2.0"
version = "0.2.1"
authors = ["Daniel Müller <[email protected]>"]
description = "A Bittorrent meta file generator"
license = "GPL-3.0+"
Expand Down
36 changes: 24 additions & 12 deletions bip_metainfo/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,7 @@ impl<'a> MetainfoBuilder<'a> {

/// Set or unset a source string for the torrent file.
pub fn set_source(mut self, opt_source: Option<&'a str>) -> MetainfoBuilder<'a> {
{
let dict_access = self.root.dict_mut().unwrap();

if let Some(source) = opt_source {
dict_access.insert(parse::SOURCE_KEY.into(), ben_bytes!(source));
} else {
dict_access.remove(parse::SOURCE_KEY);
}
}
self.info = self.info.set_source(opt_source);

self
}
Expand Down Expand Up @@ -218,9 +210,7 @@ impl<'a> MetainfoBuilder<'a> {

/// Get decoded value of source key
pub fn get_source(&self) -> Option<String> {
let dict_access = self.root.dict().unwrap();

parse::parse_source(dict_access).map(String::from)
self.info.get_source()
}

/// Get decoded value of created-by key
Expand Down Expand Up @@ -272,6 +262,28 @@ impl<'a> InfoBuilder<'a> {
self
}

/// Set or unset a source string for the torrent file.
pub fn set_source(mut self, opt_source: Option<&'a str>) -> InfoBuilder<'a> {
{
let dict_access = self.info.dict_mut().unwrap();

if let Some(source) = opt_source {
dict_access.insert(parse::SOURCE_KEY.into(), ben_bytes!(source));
} else {
dict_access.remove(parse::SOURCE_KEY);
}
}

self
}

/// Get decoded value of source key
pub fn get_source(&self) -> Option<String> {
let dict_access = self.info.dict().unwrap();

parse::parse_source(dict_access).map(String::from)
}

/// Sets the piece length for the torrent file.
pub fn set_piece_length(mut self, piece_length: PieceLength) -> InfoBuilder<'a> {
self.piece_length = piece_length;
Expand Down

0 comments on commit 697606f

Please sign in to comment.