示例#1
0
class SyncLog(tsumufs.Debuggable):
  '''
  Class that implements a queue for storing synclog entries in. Used
  primarily by the SyncThread class.
  '''

  _syncDocuments = None
  _syncChanges   = None
  _changesSeqs   = None

  _lock          = threading.RLock()


  @benchmark
  def __init__(self):
    self._syncDocuments = DocumentHelper(tsumufs.SyncDocument,
                                         tsumufs.dbName,
                                         batch=True)
    self._syncChanges   = DocumentHelper(tsumufs.SyncChangeDocument,
                                         tsumufs.dbName,
                                         batch=True)
    self._changesSeqs   = DocumentHelper(tsumufs.ChangesSequenceDocument,
                                         tsumufs.dbName,
                                         batch=True)

  def checkpoint(self):
    '''
    Checkpoint the synclog to disk.
    '''

    self._syncChanges.commit()

  @benchmark
  def isNewFile(self, fusepath):
    '''
    Check to see if fusepath is a file the user created locally.

    Returns:
      Boolean

    Raises:
      Nothing
    '''

    try:
      self._lock.acquire()

      self.getChange(filename=fusepath, type='new', pk=True)

      return True

    except tsumufs.DocumentException, e:
      return False

    finally: