1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-28 10:46:15 +01:00

mmap the file readonly, it is safer and fixes uploading of readonly files in

osc ftp
This commit is contained in:
Michal Marek 2008-08-28 09:41:42 +00:00
parent a8181f7087
commit 7f457a1d31

View File

@ -1456,9 +1456,10 @@ def http_request(method, url, headers={}, data=None, file=None):
data = open(file).read()
else:
import mmap
filefd = open(file, 'r+')
filefd = open(file, 'r')
try:
data = mmap.mmap(filefd.fileno(), os.path.getsize(file))
data = mmap.mmap(filefd.fileno(), os.path.getsize(file),
mmap.MAP_SHARED, mmap.PROT_READ)
except EnvironmentError, e:
if e.errno == 19:
sys.exit('\n\n%s\nThe file \'%s\' could not be memory mapped. It is ' \