have Mounter.mount create a tmpdir mountpoint if none is passed

This commit is contained in:
Michael Hudson-Doyle 2023-06-07 16:03:53 +12:00
parent 0dca036101
commit 285a44d54f
1 changed files with 5 additions and 2 deletions

View File

@ -118,13 +118,16 @@ class Mounter:
self.tmpfiles = TmpFileSet()
self._mounts: List[Mountpoint] = []
async def mount(self, device, mountpoint, options=None, type=None):
async def mount(self, device, mountpoint=None, options=None, type=None):
opts = []
if options is not None:
opts.extend(['-o', options])
if type is not None:
opts.extend(['-t', type])
if os.path.exists(mountpoint):
if mountpoint is None:
mountpoint = tempfile.mkdtemp()
created = True
elif os.path.exists(mountpoint):
created = False
else:
path = Path(device)