File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,7 @@ type FlagStorage struct {
106
106
PreferPatchUploads bool
107
107
NoPreloadDir bool
108
108
NoVerifySSL bool
109
+ WinRefreshDirs bool
109
110
110
111
// Debugging
111
112
DebugMain bool
Original file line number Diff line number Diff line change @@ -140,6 +140,11 @@ MISC OPTIONS:
140
140
Value : gid ,
141
141
Usage : "Drop root group and change to this group ID (defaults to --gid)." ,
142
142
},
143
+
144
+ cli.BoolFlag {
145
+ Name : "refresh-dirs" ,
146
+ Usage : "Automatically refresh open directories using notifications under Windows" ,
147
+ },
143
148
}
144
149
145
150
s3Flags := []cli.Flag {
@@ -845,6 +850,7 @@ func PopulateFlags(c *cli.Context) (ret *FlagStorage) {
845
850
Gid : uint32 (c .Int ("gid" )),
846
851
Setuid : c .Int ("setuid" ),
847
852
Setgid : c .Int ("setgid" ),
853
+ WinRefreshDirs : c .Bool ("refresh-dirs" ),
848
854
849
855
// Tuning,
850
856
MemoryLimit : uint64 (1024 * 1024 * c .Int ("memory-limit" )),
Original file line number Diff line number Diff line change @@ -76,6 +76,9 @@ func NewGoofysWin(fs *Goofys) *GoofysWin {
76
76
fs .NotifyCallback = func (notifications []interface {}) {
77
77
go fsint .Notify (notifications )
78
78
}
79
+ if fs .flags .WinRefreshDirs {
80
+ go fsint .WinDirRefresher ()
81
+ }
79
82
return fsint
80
83
}
81
84
@@ -995,6 +998,34 @@ func (fs *GoofysWin) Notify(notifications []interface{}) {
995
998
}
996
999
}
997
1000
1001
+ func (fs * GoofysWin ) WinDirRefresher () {
1002
+ for atomic .LoadInt32 (& fs .shutdown ) == 0 {
1003
+ select {
1004
+ case <- time .After (1 * time .Second ):
1005
+ case <- fs .shutdownCh :
1006
+ return
1007
+ }
1008
+ fs .mu .Lock ()
1009
+ var dirs []* Inode
1010
+ for _ , dh := range fs .dirHandles {
1011
+ dirs = append (dirs , dh .inode )
1012
+ }
1013
+ fs .mu .Unlock ()
1014
+ expireUnix := time .Now ().Add (- fs .flags .StatCacheTTL )
1015
+ notifications := make (map [string ]struct {})
1016
+ for _ , dir := range dirs {
1017
+ dir .mu .Lock ()
1018
+ if dir .Parent != nil && dir .dir .DirTime .Before (expireUnix ) {
1019
+ notifications ["/" + dir .FullName ()] = struct {}{}
1020
+ }
1021
+ dir .mu .Unlock ()
1022
+ }
1023
+ for dir := range notifications {
1024
+ fs .host .Notify (dir , fuse .NOTIFY_CHMOD | fuse .NOTIFY_CHOWN | fuse .NOTIFY_UTIME | fuse .NOTIFY_CHFLAGS | fuse .NOTIFY_TRUNCATE )
1025
+ }
1026
+ }
1027
+ }
1028
+
998
1029
// Mount the file system based on the supplied arguments, returning a
999
1030
// MountedFS that can be joined to wait for unmounting.
1000
1031
func MountWin (
You can’t perform that action at this time.
0 commit comments