Bläddra i källkod

Merge pull request #2102 from enkore/issue/2082

mount: umount on SIGINT/^C when in foreground
TW 8 år sedan
förälder
incheckning
127250c400
2 ändrade filer med 10 tillägg och 1 borttagningar
  1. 7 0
      borg/archiver.py
  2. 3 1
      borg/fuse.py

+ 7 - 0
borg/archiver.py

@@ -1546,6 +1546,13 @@ class Archiver:
         - allow_damaged_files: by default damaged files (where missing chunks were
           replaced with runs of zeros by borg check --repair) are not readable and
           return EIO (I/O error). Set this option to read such files.
+
+        When the daemonized process receives a signal or crashes, it does not unmount.
+        Unmounting in these cases could cause an active rsync or similar process
+        to unintentionally delete data.
+
+        When running in the foreground ^C/SIGINT unmounts cleanly, but other
+        signals or crashes do not.
         """)
         subparser = subparsers.add_parser('mount', parents=[common_parser],
                                           description=self.do_mount.__doc__,

+ 3 - 1
borg/fuse.py

@@ -6,6 +6,7 @@ import os
 import stat
 import tempfile
 import time
+from signal import SIGINT
 from distutils.version import LooseVersion
 
 import msgpack
@@ -98,7 +99,8 @@ class FuseOperations(llfuse.Operations):
         umount = False
         try:
             signal = fuse_main()
-            umount = (signal is None)  # no crash and no signal -> umount request
+            # no crash and no signal (or it's ^C and we're in the foreground) -> umount request
+            umount = (signal is None or (signal == SIGINT and foreground))
         finally:
             llfuse.close(umount)