Skip to content
Browse files

catch rollback exceptions raised when rolling back files and print th…

…em to stderr
  • Loading branch information...
1 parent 33b4b98 commit c41a6bfea46ed3f3e1f390f32ecc469b57b33a56 @lirazsiri lirazsiri committed
Showing with 24 additions and 18 deletions.
  1. +24 −18 rollback.py
View
42 rollback.py
@@ -9,6 +9,7 @@
# the License, or (at your option) any later version.
#
import os
+import sys
from os.path import *
import stat
@@ -23,6 +24,7 @@
from pkgman import Packages
import utils
+import traceback
class Error(Exception):
pass
@@ -87,26 +89,30 @@ def rollback_files(self):
dirindex = DirIndex(self.paths.dirindex)
for change in changes:
- if change.path not in dirindex:
- utils.remove_any(change.path)
- continue
-
- if change.OP in ('o', 'd'):
- try:
- self._move_from_originals(change.path)
- except self.Error:
+ try:
+ if change.path not in dirindex:
+ utils.remove_any(change.path)
continue
- dirindex_rec = dirindex[change.path]
- local_rec = DirIndex.Record.frompath(change.path)
-
- if dirindex_rec.uid != local_rec.uid or \
- dirindex_rec.gid != local_rec.gid:
- os.lchown(change.path, dirindex_rec.uid, dirindex_rec.gid)
-
- if dirindex_rec.mod != local_rec.mod:
- mod = stat.S_IMODE(dirindex_rec.mod)
- os.chmod(change.path, mod)
+ if change.OP in ('o', 'd'):
+ try:
+ self._move_from_originals(change.path)
+ except self.Error:
+ continue
+
+ dirindex_rec = dirindex[change.path]
+ local_rec = DirIndex.Record.frompath(change.path)
+
+ if dirindex_rec.uid != local_rec.uid or \
+ dirindex_rec.gid != local_rec.gid:
+ os.lchown(change.path, dirindex_rec.uid, dirindex_rec.gid)
+
+ if dirindex_rec.mod != local_rec.mod:
+ mod = stat.S_IMODE(dirindex_rec.mod)
+ os.chmod(change.path, mod)
+ except:
+ # fault-tolerance: warn and continue, don't die
+ traceback.print_exc(file=sys.stderr)
for fname in ('passwd', 'group'):
shutil.copy(join(self.paths.etc, fname), "/etc")

0 comments on commit c41a6bf

Please sign in to comment.
Something went wrong with that request. Please try again.