Skip to content

Commit a29ddd4

Browse files
committed
C#: Clear existing data directory extracted from PCK
1 parent e2dd56b commit a29ddd4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

modules/mono/godotsharp_dirs.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,14 @@ class _GodotSharpDirs {
192192
}
193193
}
194194
if (!has_data) {
195-
// 3. Extract the data to a temporary location to load from there.
196-
Ref<DirAccess> da = DirAccess::create_for_path(packed_path);
195+
// 3. Extract the data to a temporary location to load from there, delete old data if it exists but is not up-to-date.
196+
Ref<DirAccess> da;
197+
if (DirAccess::exists(data_dir_root)) {
198+
da = DirAccess::open(data_dir_root);
199+
ERR_FAIL_COND(da.is_null());
200+
ERR_FAIL_COND(da->erase_contents_recursive() != OK);
201+
}
202+
da = DirAccess::create_for_path(packed_path);
197203
ERR_FAIL_COND(da.is_null());
198204
ERR_FAIL_COND(da->copy_dir(packed_path, data_dir_root) != OK);
199205
}

0 commit comments

Comments
 (0)