Skip to content

Commit c83292f

Browse files
committed
[Build] Ensure .data_repos is removed before cloning
Otherwise we get permission issues overwriting read-only git files on windows
1 parent 56bd73e commit c83292f

File tree

1 file changed

+18
-38
lines changed

1 file changed

+18
-38
lines changed

xenia-build.py

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -745,14 +745,18 @@ def git_submodule_update():
745745
def fetch_data_repos():
746746
"""Fetches data repositories (game-patches, optimized-settings) into .data_repos/.
747747
748-
These repos are cloned fresh or updated to their latest versions. They are not
749-
submodules to avoid constant submodule updates in the main repo.
748+
Removes and re-clones all data repos fresh each time. They are not submodules
749+
to avoid constant submodule updates in the main repo.
750750
"""
751751
print("- fetching data repositories...")
752752

753753
data_dir = ".data_repos"
754-
if not os.path.exists(data_dir):
755-
os.makedirs(data_dir)
754+
if os.path.exists(data_dir):
755+
def remove_readonly(func, path, _):
756+
os.chmod(path, stat.S_IWRITE)
757+
func(path)
758+
rmtree(data_dir, onerror=remove_readonly)
759+
os.makedirs(data_dir)
756760

757761
# Define data repos
758762
data_repos = [
@@ -768,42 +772,18 @@ def fetch_data_repos():
768772
}
769773
]
770774

771-
# Clone or update each repo
775+
# Clone each repo fresh
772776
for repo in data_repos:
773777
repo_path = os.path.join(data_dir, repo["name"])
774-
775-
if os.path.exists(repo_path):
776-
print(f" - updating {repo['name']}...")
777-
try:
778-
shell_call([
779-
"git",
780-
"-C", repo_path,
781-
"pull",
782-
"--depth=1",
783-
"origin", repo["branch"]
784-
])
785-
except Exception as e:
786-
print(f" Warning: Failed to update {repo['name']}: {e}")
787-
print(f" Removing and re-cloning...")
788-
rmtree(repo_path)
789-
shell_call([
790-
"git",
791-
"clone",
792-
"--depth=1",
793-
"--branch", repo["branch"],
794-
repo["url"],
795-
repo_path
796-
])
797-
else:
798-
print(f" - cloning {repo['name']}...")
799-
shell_call([
800-
"git",
801-
"clone",
802-
"--depth=1",
803-
"--branch", repo["branch"],
804-
repo["url"],
805-
repo_path
806-
])
778+
print(f" - cloning {repo['name']}...")
779+
shell_call([
780+
"git",
781+
"clone",
782+
"--depth=1",
783+
"--branch", repo["branch"],
784+
repo["url"],
785+
repo_path
786+
])
807787

808788

809789
def get_cc(cc=None):

0 commit comments

Comments
 (0)