-
Notifications
You must be signed in to change notification settings - Fork 7.6k
File watchers and caching #6198
Changes from 1 commit
ec18bce
d5893e5
8a80572
a3fbbe5
277f6f7
771e73c
0ea50d4
9c7d7d7
24e3686
32c37c0
3c1e7b3
57f3085
f565420
de3f169
94a23b8
fdc6e5f
7413a2d
f628555
842656b
e050826
9a9e63b
7b296e6
75ad54f
491e3bf
0fc024e
5ee0387
b63df53
0581be8
ba1d528
1ddf393
6200ec1
d32b26a
3d40057
abe72c5
a6939e6
63ceeb0
6dbcea2
a8941da
4dbfacc
d1de067
fdf0bdd
9fb030d
28a655a
ec57b00
b7a1f6b
f4e5517
77a35d8
c6967bd
b636495
998317d
be0645b
e37614d
f3d831b
a724116
188ac33
5f16cd9
9fbbc35
4649341
afaed1f
228aa0b
b844177
e91be35
f4fd368
8634380
c3fb961
4132060
de6e962
2856bb0
cafec66
62e307a
49f99b2
71d27e4
8c39036
52cabdd
896188f
ae7f28b
54cec57
aa09120
45ffc1c
b6fbdeb
f30a4eb
e42f3db
a790803
a7a551d
febbfe6
68eef10
e1a3614
2914b98
4f07182
6262021
52f8ed3
1d608b2
8de072b
3cc8955
63896e6
c2caa78
af2b4ea
d0d5648
7e517ee
26309a5
c2680b0
db45700
5a91580
3d821fe
6e0c286
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…he FileSystem level
- v0.36.0-10998
- test-45
- sprint-41
- sprint-40
- sprint-39
- sprint-38
- sprint-37
- sprint-36
- splitview-pre-tree2
- splitview-pre-tree
- release-39
- release-1.14.2
- release-1.14.1
- release-1.14
- release-1.14-prerelease-1
- release-1.13
- release-1.13-prerelease-3
- release-1.13-prerelease-2
- release-1.13-prerelease-1
- release-1.12
- release-1.12-prerelease
- release-1.11
- release-1.11-prerelease-2
- release-1.11-prerelease-1
- release-1.10
- release-1.10-prerelease-4
- release-1.10-prerelease-3
- release-1.10-prerelease-2
- release-1.10-prerelease-1
- release-1.9
- release-1.9-prerelease-2
- release-1.9-prerelease
- release-1.8
- release-1.8-prerelease1
- release-1.8-prerelease
- release-1.7
- release-1.7-prerelease1
- release-1.6
- release-1.6+eb4
- release-1.6-prerelease1
- release-1.5
- release-1.5+eb4
- release-1.4
- release-1.4+eb4
- release-1.4-prerelease1
- release-1.3
- release-1.3+eb4
- release-1.3-prerelease1
- release-1.2
- release-1.2+eb4
- release-1.2+eb4-Prerelease1Linux
- release-1.2-prerelease1
- release-1.2-prerelease1-Linux
- release-1.1
- release-1.1+eb4
- release-1.1-rc1
- release-1.1-prerelease1
- release-1.0
- release-1.0+eb4
- release-1.0-rc1
- release-1.0-beta1
- release-0.44
- release-0.44-beta2
- release-0.44-beta1
- release-0.43
- release-0.43-beta1
- release-0.42
- release-0.41
- linux-cef-2171
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,8 @@ | |
define(function (require, exports, module) { | ||
"use strict"; | ||
|
||
var FileSystemEntry = require("filesystem/FileSystemEntry"); | ||
var FileSystemEntry = require("filesystem/FileSystemEntry"), | ||
FileSystemError = require("filesystem/FileSystemError"); | ||
|
||
|
||
/* | ||
|
@@ -98,10 +99,11 @@ define(function (require, exports, module) { | |
return; | ||
} | ||
|
||
this._hash = stat._hash; | ||
|
||
// Only cache the stats for and contents of watched files | ||
if (this._isWatched) { | ||
this._stat = stat; | ||
this._hash = stat._hash; | ||
this._contents = data; | ||
} | ||
|
||
|
@@ -132,26 +134,41 @@ define(function (require, exports, module) { | |
if (watched && !options.blind) { | ||
options.hash = this._hash; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How come we don't check the hash before writing to a non-watched file? It seems more important than ever in that case, and read() still does save the hash even if unwatched... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, that's good question. I can't think of any particular reason off the top of my head, except that perhaps the Another thing I was thinking about doing was to modify the |
||
} | ||
|
||
this._fileSystem._beginWrite(); | ||
|
||
this._impl.writeFile(this._path, data, options, function (err, stat) { | ||
try { | ||
if (err) { | ||
this._clearCachedData(); | ||
this._impl.writeFile(this._path, data, options, function (err, stat, created) { | ||
|
||
if (err) { | ||
this._clearCachedData(); | ||
|
||
try { | ||
callback(err); | ||
return; | ||
} finally { | ||
this._fileSystem._endWrite(); // unblock generic change events | ||
} | ||
return; | ||
} | ||
|
||
this._hash = stat._hash; | ||
|
||
try { | ||
callback(null, stat); | ||
} finally { | ||
if (created) { | ||
// new file created | ||
this._fileSystem._handleWatchResult(this._parentPath); | ||
} else { | ||
// existing file modified | ||
this._fileSystem._handleWatchResult(this._path, stat); | ||
} | ||
|
||
// Only cache the stats for and contents of watched files | ||
if (watched) { | ||
this._stat = stat; | ||
this._hash = stat._hash; | ||
this._contents = data; | ||
} | ||
|
||
callback(null, stat); | ||
} finally { | ||
this._fileSystem._endWrite(); // unblock generic change events | ||
} | ||
}.bind(this)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although this is set here in create(), it's not updated in getContents() -- so it seems like as soon as a file is added/removed, the Directory's stats are nulled out, never to return... I guess that's not so bad though, since you can explicitly re-request it later via stat()? (And unlike File, we don't rely on
this._stat
when determining how to handle water results).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's a wrinkle. It probably would have been better for
getContents
to also return the directory's stats along with those of its children. But, IMO, not a blocker.