def validate_space_limit(file_size):
 from frappe.utils.file_manager import MaxFileSizeReachedError
 limits = get_limits()
 if (not limits.space):
  return
 space_limit = flt((limits.space * 1024.0), 2)
 usage = frappe._dict((limits.space_usage or {}))
 if (not usage):
  usage = frappe._dict(update_space_usage())
 file_size = (file_size / (1024.0 ** 2))
 if (flt((flt(usage.total) + file_size), 2) > space_limit):
  frappe.throw(_(u'You have exceeded the max space of {0} for your plan. {1}.').format((u'<b>{0}MB</b>'.format(cint(space_limit)) if (space_limit < 1024) else u'<b>{0}GB</b>'.format(limits.space)), u'<a href="#usage-info">{0}</a>'.format(_(u'Click here to check your usage or upgrade to a higher plan'))), MaxFileSizeReachedError)
 usage.files_size = (flt(usage.files_size) + file_size)
 update_limits({u'space_usage': usage})

def validate_space_limit ( file_size ) : from frappe . utils . file_manager import MaxFileSizeReachedError limits = get_limits ( ) if ( not limits . space ) : return space_limit = flt ( ( limits . space * 1024.0 ) , 2 ) usage = frappe . _dict ( ( limits . space_usage or { } ) ) if ( not usage ) : usage = frappe . _dict ( update_space_usage ( ) ) file_size = ( file_size / ( 1024.0 ** 2 ) ) if ( flt ( ( flt ( usage . total ) + file_size ) , 2 ) > space_limit ) : frappe . throw ( _ ( u'You have exceeded the max space of {0} for your plan. {1}.' ) . format ( ( u'<b>{0}MB</b>' . format ( cint ( space_limit ) ) if ( space_limit < 1024 ) else u'<b>{0}GB</b>' . format ( limits . space ) ) , u'<a href="#usage-info">{0}</a>' . format ( _ ( u'Click here to check your usage or upgrade to a higher plan' ) ) ) , MaxFileSizeReachedError ) usage . files_size = ( flt ( usage . files_size ) + file_size ) update_limits ( { u'space_usage' : usage } )
stop from writing file if max space limit is reached .