From 6ebf58965e6b9f78027c94abeb58dca8bae04d86 Mon Sep 17 00:00:00 2001
From: Chris Bainbridge <chris.bainbridge@gmail.com>
Date: Fri, 29 May 2015 16:32:57 +0100
Subject: [PATCH] Detect moved file when using inotify polling
Commit 15f82c7 ("used pyinotify as change detection system when
available") introduced a regression where editing a file in vim with
default settings (writebackup=auto) would no longer cause the dev server
to be restarted. On a write, vim moves the monitored file to a backup
path, and then creating a new file in the original. The new file is not
monitored as it has a different inode. Fix this by also watching for
inotify events IN_DELETE_SELF and IN_MOVE_SELF.
---
django/utils/autoreload.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py
index f4ac497..6efd6c4 100644
a
|
b
|
def inotify_code_changed():
|
175 | 175 | pyinotify.IN_ATTRIB | |
176 | 176 | pyinotify.IN_MOVED_FROM | |
177 | 177 | pyinotify.IN_MOVED_TO | |
178 | | pyinotify.IN_CREATE |
| 178 | pyinotify.IN_CREATE | |
| 179 | pyinotify.IN_DELETE_SELF | |
| 180 | pyinotify.IN_MOVE_SELF |
179 | 181 | ) |
180 | 182 | for path in gen_filenames(only_new=True): |
181 | 183 | wm.add_watch(path, mask) |