From ef7121dfb3e8a01b057ee099a4a2deb4a55a153e Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Mon, 2 Jul 2012 17:47:54 -0700 Subject: [PATCH] File does not trigger 'contents-change' when its md5 does not change --- src/app/file.coffee | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/file.coffee b/src/app/file.coffee index b025bfc7d..c19c54a22 100644 --- a/src/app/file.coffee +++ b/src/app/file.coffee @@ -5,7 +5,11 @@ _ = require 'underscore' module.exports = class File + path: null + md5: null + constructor: (@path) -> + @updateMd5() getPath: -> @path @@ -13,6 +17,9 @@ class File getName: -> fs.base(@path) + updateMd5: -> + @md5 = fs.md5ForPath(@path) + afterSubscribe: -> @subscribeToNativeChangeEvents() if @subscriptionCount() == 1 @@ -21,7 +28,10 @@ class File subscribeToNativeChangeEvents: -> @watchId = $native.watchPath @path, (eventTypes) => - @trigger 'contents-change' if eventTypes.modified? + newMd5 = fs.md5ForPath(@getPath()) + if eventTypes.modified? and newMd5 != @md5 + @md5 = newMd5 + @trigger 'contents-change' unsubscribeFromNativeChangeEvents: -> $native.unwatchPath(@path, @watchId)