Closed effigies closed 8 years ago
Updated SplitList
to permit silent rejection of empty elements, which makes sense in these cases. It also works for announce-list
, as [['']]
reduces by this rule to [[]]
, which reduces to []
, so any of these possible representations of an empty announce-list will be ignored.
So we end up in the following situation:
AnnounceList(x) = []
for the following values of x
: ""
, []
, [""]
, [[]]
, [[""]]
.MetaInfo
that is created with an empty announce-list
will remove it immediately, so it won't be saved. This includes a MetaInfo
that is read from a file, so malformed .torrent
files won't cause problems when run, and will be fixed if re-saved.MetaInfo
that has an empty announce-list
inserted will represent it as []
. {'announce-list': []}
has a bencoding
value of d13:announce-listlee
. This will be written, wasting 18 bytes, but an empty list shouldn't cause programs trouble.This seems to resolve the issues in #36, namely passing ''
to Announce()
and creating .torrent
files with empty fields.
Turned out btreannounce wasn't working correctly, so fix that in the process.
Perhaps we should warn when changing MetaInfo?
Another alternative is to update
TypedList
to simply ignore empty strings, which has the dubious advantage of not fixing broken metafiles on resave.Closes #36.