Example #1
0
def deletefileinvessel(vesselname,filename):
  if vesselname not in vesseldict:
    raise BadRequest, "No such vessel"
  
  try:
    _assert_is_allowed_filename(filename)
  except TypeError, e:
    raise BadRequest(str(e))
Example #2
0
def addfiletovessel(vesselname,filename, filedata):
  if vesselname not in vesseldict:
    raise BadRequest, "No such vessel"

  # get the current amount of data used by the vessel...
  currentsize = nonportable.compute_disk_use(vesselname+"/")
  # ...and the allowed amount
  resourcedict = resourcemanipulation.read_resourcedict_from_file(vesseldict[vesselname]['resourcefilename'])

  # If the current size + the size of the new data is too large, then deny
  if currentsize + len(filedata) > resourcedict['diskused']:
    raise BadRequest("Not enough free disk space")
  
  try:
    _assert_is_allowed_filename(filename)
  except TypeError, e:
    raise BadRequest(str(e))