Remove partial image data when filesystem is full

When an image is uploaded that fills up the local filesystem, attempt
to delete the created file. This only applies to the 'filesystem'
store driver.

Fixes bug 1019421

Change-Id: Ie12d736f3efb29b0862fef2899a1d2c142def38e
This commit is contained in:
Brian Waldon 2012-08-22 09:12:15 -07:00
parent 32584bed6c
commit 37d1c1d83c

View File

@ -210,6 +210,11 @@ class Store(glance.store.base.Store):
f.write(buf)
except IOError as e:
if e.errno in [errno.EFBIG, errno.ENOSPC]:
try:
os.unlink(filepath)
except Exception:
msg = _('Unable to remove partial image data for image %s')
LOG.error(msg % image_id)
raise exception.StorageFull()
elif e.errno == errno.EACCES:
raise exception.StorageWriteDenied()