Skip to content

Commit

Permalink
Doing this move event handling properly
Browse files Browse the repository at this point in the history
  • Loading branch information
da2x committed Jul 24, 2015
1 parent ecd5f91 commit 14734f6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions nikola/plugins/command/auto/__init__.py
Expand Up @@ -248,12 +248,15 @@ def __call__(self, environ, start_response):
os.kill(os.getpid(), 15)

def do_rebuild(self, event):
fname = os.path.basename(event.src_path)
# Move events have a dest_path, some editors like gedit use a
# move on larger save operations for write protection
event_path = event.dest_path if hasattr(event, 'dest_path') else event.src_path
fname = os.path.basename(event_path)
if (fname.endswith('~') or
fname.startswith('.') or
os.path.isdir(event.src_path)): # Skip on folders, these are usually duplicates
os.path.isdir(event_path)): # Skip on folders, these are usually duplicates
return
self.logger.info('REBUILDING SITE (from {0})'.format(event.src_path))
self.logger.info('REBUILDING SITE (from {0})'.format(event_path))
p = subprocess.Popen(self.cmd_arguments, stderr=subprocess.PIPE)
error = p.stderr.read()
errord = error.decode('utf-8')
Expand All @@ -266,7 +269,7 @@ def do_rebuild(self, event):
def do_refresh(self, event):
# Move events have a dest_path, some editors like gedit use a
# move on larger save operations for write protection
event_path = event.dest_path if event.dest_path else event.src_path
event_path = event.dest_path if hasattr(event, 'dest_path') else event.src_path
self.logger.info('REFRESHING: {0}'.format(event_path))
p = os.path.relpath(event_path, os.path.abspath(self.site.config['OUTPUT_FOLDER']))
refresh_signal.send(path=p)
Expand Down

0 comments on commit 14734f6

Please sign in to comment.