Check if workpath/ is empty and in that case create workpath/version (MR 1975)

Fixes https://gitlab.com/postmarketOS/pmbootstrap/-/issues/1965
This commit is contained in:
Henrik Grimler 2020-09-14 19:01:19 +02:00
parent 1b5120e24f
commit efd64f7714
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -60,6 +60,10 @@ def ask_for_work_path(args):
# Create the folder with a version file
if not exists:
os.makedirs(work, 0o700, True)
if not os.listdir(work):
# Directory is empty, either because we just created it or
# because user created it before running pmbootstrap init
with open(work + "/version", "w") as handle:
handle.write(str(pmb.config.work_version) + "\n")