]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/cmd/fuse.py
Replace LocalRepo/RemoteRepo __del__ with context management
[bup.git] / lib / bup / cmd / fuse.py
index 385bea9f3a8d0f2d8865db310afce464f97a8f22..27937123835c43cd2f8498d5d1d5e95a26f73773 100755 (executable)
@@ -147,17 +147,17 @@ def main(argv):
         o.fatal('only one mount point argument expected')
 
     git.check_repo_or_die()
-    repo = LocalRepo()
-    f = BupFs(repo=repo, verbose=opt.verbose, fake_metadata=(not opt.meta))
-
-    # This is likely wrong, but the fuse module doesn't currently accept bytes
-    f.fuse_args.mountpoint = extra[0]
-
-    if opt.debug:
-        f.fuse_args.add('debug')
-    if opt.foreground:
-        f.fuse_args.setmod('foreground')
-    f.multithreaded = False
-    if opt.allow_other:
-        f.fuse_args.add('allow_other')
-    f.main()
+    with LocalRepo() as repo:
+        f = BupFs(repo=repo, verbose=opt.verbose, fake_metadata=(not opt.meta))
+
+        # This is likely wrong, but the fuse module doesn't currently accept bytes
+        f.fuse_args.mountpoint = extra[0]
+
+        if opt.debug:
+            f.fuse_args.add('debug')
+        if opt.foreground:
+            f.fuse_args.setmod('foreground')
+        f.multithreaded = False
+        if opt.allow_other:
+            f.fuse_args.add('allow_other')
+        f.main()