Catch exception from os.stat in attachment

An OSError exception can occurs if the file is no more there or if the
data_path is wrong.
This commit is contained in:
Cédric Krier committed 2010-03-23 10:54:27 +01:00
1 parent 0a238cd62f
commit a171da0ef3
1 file changed
+5 -2
+5 -2
View File
@@ -51,8 +51,11 @@ class Attachment(ModelSQL, ModelView):
filename = os.path.join(CONFIG['data_path'], db_name,
filename[0:2], filename[2:4], filename)
if name == 'datas_size':
statinfo = os.stat(filename)
value = statinfo.st_size
try:
statinfo = os.stat(filename)
value = statinfo.st_size
except OSError:
pass
else:
try:
file_p = open(filename, 'rb')