Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f668d17e
Commit
f668d17e
authored
Jun 06, 1997
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clear the ftp cache when it contains more than 10 entries.
parent
2966b322
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
2 deletions
+21
-2
Lib/urllib.py
Lib/urllib.py
+21
-2
No files found.
Lib/urllib.py
View file @
f668d17e
...
...
@@ -28,7 +28,9 @@ import os
import
sys
__version__
=
'1.6'
__version__
=
'1.7'
MAXFTPCACHE
=
10
# Trim the ftp cache beyond this size
# Helper for non-unix systems
if
os
.
name
==
'mac'
:
...
...
@@ -317,6 +319,13 @@ class URLopener:
dirs
,
file
=
dirs
[:
-
1
],
dirs
[
-
1
]
if
dirs
and
not
dirs
[
0
]:
dirs
=
dirs
[
1
:]
key
=
(
user
,
host
,
port
,
string
.
joinfields
(
dirs
,
'/'
))
if
len
(
self
.
ftpcache
)
>
MAXFTPCACHE
:
# Prune the cache, rather arbitrarily
for
k
in
self
.
ftpcache
.
keys
():
if
k
!=
key
:
v
=
self
.
ftpcache
[
k
]
del
self
.
ftpcache
[
k
]
v
.
close
()
try
:
if
not
self
.
ftpcache
.
has_key
(
key
):
self
.
ftpcache
[
key
]
=
\
...
...
@@ -506,7 +515,17 @@ class ftpwrapper:
if
file
:
cmd
=
'LIST '
+
file
else
:
cmd
=
'LIST'
conn
=
self
.
ftp
.
transfercmd
(
cmd
)
return
addclosehook
(
conn
.
makefile
(
'rb'
),
self
.
ftp
.
voidresp
)
return
addclosehook
(
conn
.
makefile
(
'rb'
),
self
.
endtransfer
)
def
endtransfer
(
self
):
try
:
self
.
ftp
.
voidresp
()
except
ftperrors
():
pass
def
close
(
self
):
try
:
self
.
ftp
.
close
()
except
ftperrors
():
pass
# Base class for addinfo and addclosehook
class
addbase
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment