@@ -83,8 +83,8 @@ def _callback(self, events):
83
83
for event in events :
84
84
if isinstance (event , MapEvent ):
85
85
current = self ._ycontent
86
- for path in event .path :
87
- current = current [path ]
86
+ for p in event .path :
87
+ current = current [p ]
88
88
for key , val in event .keys .items ():
89
89
action = val .get ("action" )
90
90
if action == "delete" :
@@ -101,13 +101,17 @@ def _callback(self, events):
101
101
self ._task_group .start_soon (self ._try_create_directory , path )
102
102
else :
103
103
self ._task_group .start_soon (self ._try_create_file , path )
104
+ elif action == "update" :
105
+ if key == "populate" and not val ["oldValue" ] and val ["newValue" ]:
106
+ path = "/" .join (event .path [1 ::2 ])
107
+ self ._task_group .start_soon (self .ls , path )
104
108
105
109
@property
106
110
def version (self ) -> str :
107
111
return "1.0.0"
108
112
109
113
def _new_dir_content (self ) -> Map :
110
- return Map ({"is_dir" : True , "content" : None })
114
+ return Map ({"is_dir" : True , "populate" : False , " content" : None })
111
115
112
116
def _new_file_content (self , content : Content | None = None ) -> Map :
113
117
if content is None :
@@ -153,7 +157,10 @@ async def _get_directory_content(self, path: Path) -> Map:
153
157
154
158
async def _maybe_populate_dir (self , path : Path , content : Map ):
155
159
if content ["content" ] is None :
156
- content ["content" ] = await self ._get_directory_content (path )
160
+ with content .doc .transaction ():
161
+ content ["content" ] = await self ._get_directory_content (path )
162
+ if not content ["populate" ]:
163
+ content ["populate" ] = True
157
164
158
165
async def _get (self , path : Path | str | None = None ) -> Map :
159
166
path = Path () if path is None else Path (path )
0 commit comments