mirror of
https://github.com/certbot/certbot.git
synced 2026-07-30 18:04:31 +02:00
Added recovery function
This commit is contained in:
+25
-6
@@ -206,9 +206,9 @@ class RenewableCert(object): # pylint: disable=too-many-instance-attributes
|
|||||||
# filesystem errors, or crashes.)
|
# filesystem errors, or crashes.)
|
||||||
|
|
||||||
def _lockfiles(self):
|
def _lockfiles(self):
|
||||||
"""Returns the path of all lockfiles used by this lineage.
|
"""Returns the kind and path of all used lockfiles.
|
||||||
|
|
||||||
:returns: the path of all lockfiles used by this lineage
|
:returns: list of (kind, lockfile) tuples
|
||||||
:rtype: list
|
:rtype: list
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -216,10 +216,30 @@ class RenewableCert(object): # pylint: disable=too-many-instance-attributes
|
|||||||
for kind in ALL_FOUR:
|
for kind in ALL_FOUR:
|
||||||
lock_dir = os.path.dirname(getattr(self, kind))
|
lock_dir = os.path.dirname(getattr(self, kind))
|
||||||
lock_base = "{0}.lock".format(kind)
|
lock_base = "{0}.lock".format(kind)
|
||||||
lockfiles.append(os.path.join(lock_dir, lock_base))
|
lockfiles.append((kind, os.path.join(lock_dir, lock_base)))
|
||||||
|
|
||||||
return lockfiles
|
return lockfiles
|
||||||
|
|
||||||
|
def _fix_symlinks(self):
|
||||||
|
"""Fixes symlinks in the event of an incomplete version update.
|
||||||
|
|
||||||
|
If there is no problem with the current symlinks, this function
|
||||||
|
has no effect.
|
||||||
|
|
||||||
|
"""
|
||||||
|
lockfiles = self._lockfiles()
|
||||||
|
if all(os.path.exists(lockfile) for lockfile in lockfiles):
|
||||||
|
for kind, lockfile in lockfiles:
|
||||||
|
link = getattr(self, kind)
|
||||||
|
if os.path.lexists(link):
|
||||||
|
os.unlink(link)
|
||||||
|
with open(lockfile) as f:
|
||||||
|
os.symlink(f.readline().rstrip(), link)
|
||||||
|
else:
|
||||||
|
for _, lockfile in lockfiles:
|
||||||
|
if os.path.exists(lockfile):
|
||||||
|
os.unlink(lockfile)
|
||||||
|
|
||||||
def current_target(self, kind):
|
def current_target(self, kind):
|
||||||
"""Returns full path to which the specified item currently points.
|
"""Returns full path to which the specified item currently points.
|
||||||
|
|
||||||
@@ -395,15 +415,14 @@ class RenewableCert(object): # pylint: disable=too-many-instance-attributes
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
lockfiles = self._lockfiles()
|
lockfiles = self._lockfiles()
|
||||||
for lockfile in lockfiles:
|
for kind, lockfile in lockfiles:
|
||||||
kind = os.path.splitext(os.path.basename(lockfile))[0]
|
|
||||||
with open(lockfile, "w") as f:
|
with open(lockfile, "w") as f:
|
||||||
f.write("{0}\n".format(self.current_target(kind)))
|
f.write("{0}\n".format(self.current_target(kind)))
|
||||||
|
|
||||||
for kind in ALL_FOUR:
|
for kind in ALL_FOUR:
|
||||||
self._update_link_to(kind, version)
|
self._update_link_to(kind, version)
|
||||||
|
|
||||||
for lockfile in lockfiles:
|
for _, lockfile in lockfiles:
|
||||||
os.unlink(lockfile)
|
os.unlink(lockfile)
|
||||||
|
|
||||||
def _notafterbefore(self, method, version):
|
def _notafterbefore(self, method, version):
|
||||||
|
|||||||
Reference in New Issue
Block a user