diff --git a/linkcheck/checker/ftpurl.py b/linkcheck/checker/ftpurl.py index cf776655..e79c08a8 100644 --- a/linkcheck/checker/ftpurl.py +++ b/linkcheck/checker/ftpurl.py @@ -18,7 +18,7 @@ Handle FTP links. """ import ftplib -from io import StringIO +from io import BytesIO from .. import log, LOG_CHECK, LinkCheckerError, mimeutil from . import internpaturl, get_index_html @@ -179,12 +179,12 @@ class FtpUrl(internpaturl.InternPatternUrl): else: # download file in BINARY mode ftpcmd = f"RETR {self.filename}" - buf = StringIO() + buf = BytesIO() def stor_data(s): """Helper method storing given data""" # limit the download size - if (buf.tell() + len(s)) > self.max_size: + if (buf.tell() + len(s)) > self.aggregate.config["maxfilesizedownload"]: raise LinkCheckerError(_("FTP file size too large")) buf.write(s) diff --git a/tests/checker/test_ftp.py b/tests/checker/test_ftp.py index da692007..6f597f7a 100644 --- a/tests/checker/test_ftp.py +++ b/tests/checker/test_ftp.py @@ -33,6 +33,7 @@ class TestFtp(FtpServerTest): "real url %s" % url, "valid", ] + self.direct(url, resultlines) # ftp use/password user = "anonymous" passwd = "Ftp"