Esempio n. 1
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))
Esempio n. 2
0
def addfiletovessel(vesselname,filename, filedata):
  if vesselname not in vesseldict:
    raise BadRequest, "No such vessel"

  # The user is restricted from using filename starting with 'private_' since
  # this part of the namespace is reserved for custom security layers.
  if filename.startswith("private_"):
    raise BadRequest("User is not allowed to use file names starting with 'private_'")

  # get the current amount of data used by the vessel...
  currentsize = nonportable.compute_disk_use(vesselname+"/")
  # ...and the allowed amount
  resourcedict, call_list = 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:
    check_repy_filename(filename)
  except TypeError, e:
    raise BadRequest(str(e))
Esempio n. 3
0
def addfiletovessel(vesselname, filename, filedata):
    if vesselname not in vesseldict:
        raise BadRequest, "No such vessel"

    # The user is restricted from using filename starting with 'private_' since
    # this part of the namespace is reserved for custom security layers.
    if filename.startswith("private_"):
        raise BadRequest(
            "User is not allowed to use file names starting with 'private_'")

    # get the current amount of data used by the vessel...
    currentsize = nonportable.compute_disk_use(vesselname + "/")
    # ...and the allowed amount
    resourcedict, call_list = 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:
        check_repy_filename(filename)
    except RepyArgumentError, e:
        raise BadRequest(str(e))