3713: Retry hdiutil create if it fails (fixes #3711) r=heinrich5991 a=def-

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2021-03-16 17:15:18 +00:00 committed by GitHub
commit af935dcb47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,7 @@ import os
import shlex import shlex
import subprocess import subprocess
import tempfile import tempfile
import time
ConfigDmgtools = namedtuple('Config', 'dmg hfsplus newfs_hfs verbose') ConfigDmgtools = namedtuple('Config', 'dmg hfsplus newfs_hfs verbose')
ConfigHdiutil = namedtuple('Config', 'hdiutil verbose') ConfigHdiutil = namedtuple('Config', 'hdiutil verbose')
@ -72,7 +73,16 @@ class Hdiutil(Dmg):
def create(self, dmg, volume_name, directory, symlinks): def create(self, dmg, volume_name, directory, symlinks):
if symlinks: if symlinks:
raise NotImplementedError("symlinks are not yet implemented") raise NotImplementedError("symlinks are not yet implemented")
self._hdiutil('create', '-volname', volume_name, '-srcdir', directory, dmg) for i in range(5):
try:
self._hdiutil('create', '-volname', volume_name, '-srcdir', directory, dmg)
except subprocess.CalledProcessError as e:
if i == 4:
raise e
print("Retrying hdiutil create")
time.sleep(5)
else:
break
def main(): def main():
p = argparse.ArgumentParser(description="Manipulate dmg archives") p = argparse.ArgumentParser(description="Manipulate dmg archives")