Skip to content

Commit

Permalink
Merge pull request #100 from alexpdev/Fixes_#96
Browse files Browse the repository at this point in the history
updated changelog and fixed coverage gaps
  • Loading branch information
alexpdev authored Mar 17, 2022
2 parents 8867a5e + 733f6f8 commit 7128e7b
Show file tree
Hide file tree
Showing 10 changed files with 167 additions and 6 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# TorrentFile

## Version 0.6.13

- Fixed bug that created a torrent file with no name.
- Fixed bug that would error if cli path was listed after announce urls
- Added full unicode support.
- Added Unittests for new features and bug fixes

---------------------

## Version 0.6.11

- Fixed bug that occured during recheck when file of 0 length is included.
Expand Down
22 changes: 22 additions & 0 deletions docs/changelog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,13 @@
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>

<li class="md-nav__item">
<a href="#version-0613" class="md-nav__link">
Version 0.6.13
</a>

</li>

<li class="md-nav__item">
<a href="#version-0611" class="md-nav__link">
Version 0.6.11
Expand Down Expand Up @@ -580,6 +587,13 @@
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>

<li class="md-nav__item">
<a href="#version-0613" class="md-nav__link">
Version 0.6.13
</a>

</li>

<li class="md-nav__item">
<a href="#version-0611" class="md-nav__link">
Version 0.6.11
Expand Down Expand Up @@ -809,6 +823,14 @@


<h1 id="torrentfile">TorrentFile</h1>
<h2 id="version-0613">Version 0.6.13</h2>
<ul>
<li>Fixed bug that created a torrent file with no name.</li>
<li>Fixed bug that would error if cli path was listed after announce urls</li>
<li>Added full unicode support.</li>
<li>Added Unittests for new features and bug fixes</li>
</ul>
<hr />
<h2 id="version-0611">Version 0.6.11</h2>
<ul>
<li>Fixed bug that occured during recheck when file of 0 length is included.</li>
Expand Down
Binary file modified docs/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/search/search_index.json

Large diffs are not rendered by default.

Binary file modified docs/sitemap.xml.gz
Binary file not shown.
92 changes: 88 additions & 4 deletions docs/source/index.html

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions site/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# TorrentFile

## Version 0.6.13

- Fixed bug that created a torrent file with no name.
- Fixed bug that would error if cli path was listed after announce urls
- Added full unicode support.
- Added Unittests for new features and bug fixes

---------------------

## Version 0.6.11

- Fixed bug that occured during recheck when file of 0 length is included.
Expand Down
32 changes: 32 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,35 @@ def test_cli_announce_path(dir2, flag):
sys.argv = args
main()
assert os.path.exists(str(dir2) + ".torrent")


@pytest.mark.parametrize("version", ["1", "2", "3"])
def test_cli_unicode_path(version):
"""
Test creating a new torrent file with unicode characters.
"""
text = "丂七万丈三上下丌不与丏丑丒专且丕世丗丘丙业丛东丝丠両丢丣两严丩个丫丬中丮丯"
parent = os.path.dirname(__file__)
dest = os.path.join(parent, text)
with open(dest, "wb") as tempfile:
l = 0
out = text
while l < 1 << 18:
tempfile.write((out + "\n").encode("utf-8"))
l += len(out)
out += out
args = [
"torrentfile",
"create",
"--private",
"-a",
"https://tracker1.org",
"https://tracker2.org",
"--meta-version",
version,
dest,
]
sys.argv = args
main()
assert os.path.exists(dest)
rmpath(dest)
5 changes: 4 additions & 1 deletion torrentfile/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ def execute(args=None):
args = sys.argv[1:]
else:
args = ["-h"]

parser = ArgumentParser(
"torrentfile",
description="""
Expand Down Expand Up @@ -456,6 +455,10 @@ def execute(args=None):

info_parser.set_defaults(func=info_command)

for i, arg in enumerate(args):
if hasattr(arg, "decode"):
args[i] = args[i].decode("utf-8") # pragma: nocover

args = parser.parse_args(args)
if args.debug:
torrentfile.add_handler()
Expand Down
2 changes: 2 additions & 0 deletions torrentfile/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ def filelist_total(pathstring: str) -> os.PathLike:
MissingPathError
File could not be found.
"""
if hasattr(pathstring, "decode"):
pathstring = pathstring.decode("utf-8") # pragma: nocover
if os.path.exists(pathstring):
path = Path(pathstring)
return _filelist_total(path)
Expand Down

0 comments on commit 7128e7b

Please sign in to comment.