Changeset - 502f0d532fd0
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 12 years ago 2013-06-15 07:16:11
drewp@bigasterisk.com
try harder not to lose notifications on a file after one edit in emacs
Ignore-this: a1dc276d1f953ec9978a10e9744c674a
1 file changed with 24 insertions and 23 deletions:
0 comments (0 inline, 0 general)
light9/rdfdb/graphfile.py
Show inline comments
 
@@ -58,33 +58,34 @@ class GraphFile(object):
 
        notifier.watch(FilePath(path), callbacks=[self.notify])
 
      
 
    def notify(self, notifier, filepath, mask):
 
        maskNames = humanReadableMask(mask)
 
        if maskNames[0] == 'delete_self':
 
            if not filepath.exists():
 
                log.info("%s delete_self", filepath)
 
                self.fileGone()
 
        try:
 
            maskNames = humanReadableMask(mask)
 
            if maskNames[0] == 'delete_self':
 
                if not filepath.exists():
 
                    log.info("%s delete_self", filepath)
 
                    self.fileGone()
 
                    return
 
                else:
 
                    log.warn("%s delete_self event but file is here. ignoring",
 
                             filepath)
 
                return
 
            else:
 
                log.warn("%s delete_self event but file is here. ignoring",
 
                         filepath)
 
            return
 

	
 
        # we could filter these out in the watch() call, but I want
 
        # the debugging
 
        if maskNames[0] in ['open', 'access', 'close_nowrite', 'attrib']:
 
            log.debug("%s %s event, ignoring" % (filepath, maskNames))
 
            return
 
            # we could filter these out in the watch() call, but I want
 
            # the debugging
 
            if maskNames[0] in ['open', 'access', 'close_nowrite', 'attrib']:
 
                log.debug("%s %s event, ignoring" % (filepath, maskNames))
 
                return
 

	
 
        try:
 
            if filepath.getModificationTime() == self.lastWriteTimestamp:
 
                log.debug("%s changed, but we did this write", filepath)
 
            try:
 
                if filepath.getModificationTime() == self.lastWriteTimestamp:
 
                    log.debug("%s changed, but we did this write", filepath)
 
                    return
 
            except OSError as e:
 
                log.error("%s: %r" % (filepath, e))
 
                return
 
        except OSError as e:
 
            log.error("%s: %r" % (filepath, e))
 
            return
 
            
 
        log.info("%s needs reread because of %s event", filepath, maskNames)
 
        try:
 

	
 
            log.info("%s needs reread because of %s event", filepath, maskNames)
 

	
 
            self.reread()
 
        except Exception:
 
            traceback.print_exc()
0 comments (0 inline, 0 general)