Block overwriting when creating sample project
This commit is contained in:
@@ -513,6 +513,13 @@ class ProjectBuilder:
|
|||||||
"""Make a copy of the sample project by extracting the
|
"""Make a copy of the sample project by extracting the
|
||||||
sample.zip file to the new path.
|
sample.zip file to the new path.
|
||||||
"""
|
"""
|
||||||
|
if path.exists():
|
||||||
|
SHARED.error(self.tr(
|
||||||
|
"The target folder already exists. "
|
||||||
|
"Please choose another folder."
|
||||||
|
))
|
||||||
|
return False
|
||||||
|
|
||||||
if (sample := CONFIG.assetPath("sample.zip")).is_file():
|
if (sample := CONFIG.assetPath("sample.zip")).is_file():
|
||||||
try:
|
try:
|
||||||
shutil.unpack_archive(sample, path)
|
shutil.unpack_archive(sample, path)
|
||||||
|
|||||||
@@ -651,7 +651,7 @@ def testCoreTools_ProjectBuilderSample(monkeypatch, mockGUI, fncPath, tstPaths):
|
|||||||
data = {
|
data = {
|
||||||
"name": "Test Sample",
|
"name": "Test Sample",
|
||||||
"author": "Jane Doe",
|
"author": "Jane Doe",
|
||||||
"path": fncPath,
|
"path": fncPath / "project",
|
||||||
"sample": True,
|
"sample": True,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,6 +684,9 @@ def testCoreTools_ProjectBuilderSample(monkeypatch, mockGUI, fncPath, tstPaths):
|
|||||||
zipObj.write(docFile, f"content/{docFile.name}")
|
zipObj.write(docFile, f"content/{docFile.name}")
|
||||||
|
|
||||||
assert builder.buildProject(data) is True
|
assert builder.buildProject(data) is True
|
||||||
|
|
||||||
|
# Can't create to the same target again
|
||||||
|
assert builder.buildProject(data) is False
|
||||||
dstSample.unlink()
|
dstSample.unlink()
|
||||||
|
|
||||||
# END Test testCoreTools_ProjectBuilderSample
|
# END Test testCoreTools_ProjectBuilderSample
|
||||||
|
|||||||
Reference in New Issue
Block a user