File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ def commit(self) -> None:
137137 dest .unlink ()
138138
139139 # Copy files from upper to target
140+ synced_dirs = set ()
140141 for root , dirs , files in os .walk (upper ):
141142 rel = os .path .relpath (root , upper )
142143 for d in dirs :
@@ -147,6 +148,17 @@ def commit(self) -> None:
147148 dest = target / rel / f
148149 dest .parent .mkdir (parents = True , exist_ok = True )
149150 shutil .copy2 (str (src ), str (dest ))
151+ synced_dirs .add (str (dest .parent ))
152+
153+ # fsync all modified directories to ensure data is on disk
154+ # before removing the upper dir
155+ for d in synced_dirs :
156+ try :
157+ fd = os .open (d , os .O_RDONLY | os .O_DIRECTORY )
158+ os .fsync (fd )
159+ os .close (fd )
160+ except OSError :
161+ pass
150162
151163 cleanup_branch_dir (self ._storage , self ._branch_id )
152164 self ._finished = True
You can’t perform that action at this time.
0 commit comments