Revision dc31eae3 lib/backend.py

b/lib/backend.py
1655 1655
  return result
1656 1656

  
1657 1657

  
1658
def JobQueueUpdate(file_name, content):
1659
  """Updates a file in the queue directory.
1658
def _IsJobQueueFile(file_name):
1659
  """Checks whether the given filename is in the queue directory.
1660 1660

  
1661 1661
  """
1662 1662
  queue_dir = os.path.normpath(constants.QUEUE_DIR)
1663
  if os.path.commonprefix([queue_dir, file_name]) != queue_dir:
1663
  result = (os.path.commonprefix([queue_dir, file_name]) == queue_dir)
1664

  
1665
  if not result:
1664 1666
    logging.error("'%s' is not a file in the queue directory",
1665 1667
                  file_name)
1668

  
1669
  return result
1670

  
1671

  
1672
def JobQueueUpdate(file_name, content):
1673
  """Updates a file in the queue directory.
1674

  
1675
  """
1676
  if not _IsJobQueueFile(file_name):
1666 1677
    return False
1667 1678

  
1668 1679
  # Write and replace the file atomically

Also available in: Unified diff