Check for presence of lockfile value before proceeding with context manager

This commit is contained in:
Eric Torres 2019-04-15 23:51:00 -07:00
parent 4523d0c79d
commit 2d050eaaf9

View File

@ -71,13 +71,15 @@ class PackageManager:
:rtype: ``PackageManager`` object
:raises FileExistsError: if lockfile exists when this method is called
"""
self._lockfile.touch(mode=0o000)
if self._lockfile:
self._lockfile.touch(mode=0o000, exist_ok=False)
yield self
def __exit__(self):
"""Remove the package manager's lockfile. After this lockfile is closed,
the package manager this class abstracts can perform transactions once again.
"""
if self._lockfile:
self._lockfile.unlink()
def gen_pkglist(self):