~soren/filecache/trunk-fail

« back to all changes in this revision

Viewing changes to filecache/lib/sharedfile.py

  • Committer: Rick Harris
  • Date: 2010-04-21 22:46:15 UTC
  • Revision ID: git-v1:34ec0ea4a1f1b724072e30d7be2c1252b0e73e1f
Avoid double-dots on lockfile. Closes #2

Show diffs side-by-side

added added

removed removed

Lines of Context:
247
247
        if not self._is_deleter:
248
248
            self.close()
249
249
 
 
250
    def _make_hidden_file_with_suffix(self, suffix):
 
251
        path, fname = os.path.split(self.path)
 
252
        if not fname.startswith('.'):
 
253
            fname = ".%s" % fname
 
254
        return os.path.join(path, "%s.%s" % (fname, suffix))
 
255
 
250
256
    def _make_lock(self):
251
257
        """ Subclasses can override this to use a different locking mechanism
252
258
        """
253
 
        path, fname = os.path.split(self.path)
254
 
        return FileLock(os.path.join(path, ".%s.lock" % fname))
 
259
        return FileLock(self._make_hidden_file_with_suffix('lock'))
255
260
 
256
261
    def _make_readers_semaphore(self):
257
262
        """ Subclasses can override this to use a different semaphore mechanism
258
263
        """
259
 
        path, fname = os.path.split(self.path)
260
 
        return FileSemaphore(os.path.join(path, ".%s.readers_sem" % fname))
 
264
        return FileSemaphore(self._make_hidden_file_with_suffix('readers_sem'))
261
265