zfs-check fixes and tests
This commit is contained in:
		| @ -1,6 +1,9 @@ | ||||
| import time | ||||
|  | ||||
| import argparse | ||||
| from signal import signal, SIGPIPE | ||||
| from .util import output_redir | ||||
|  | ||||
| from .ZfsAuto import ZfsAuto | ||||
|  | ||||
| from . import compressors | ||||
| @ -489,6 +492,8 @@ class ZfsAutobackup(ZfsAuto): | ||||
| def cli(): | ||||
|     import sys | ||||
|  | ||||
|     signal(SIGPIPE, output_redir) | ||||
|  | ||||
|     sys.exit(ZfsAutobackup(sys.argv[1:], False).run()) | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -1,4 +1,7 @@ | ||||
| # from util import activate_volume_snapshot, create_mountpoints, cleanup_mountpoint | ||||
| from signal import signal, SIGPIPE | ||||
| from .util import output_redir | ||||
|  | ||||
| from .ZfsAuto import ZfsAuto | ||||
| from .ZfsNode import ZfsNode | ||||
| import sys | ||||
| @ -302,6 +305,8 @@ class ZfsAutoverify(ZfsAuto): | ||||
| def cli(): | ||||
|     import sys | ||||
|  | ||||
|     signal(SIGPIPE, output_redir) | ||||
|  | ||||
|     sys.exit(ZfsAutoverify(sys.argv[1:], False).run()) | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -1,5 +1,8 @@ | ||||
| from __future__ import print_function | ||||
|  | ||||
| from signal import signal, SIGPIPE | ||||
|  | ||||
|  | ||||
| from .ZfsNode import ZfsNode | ||||
| from .util import * | ||||
| from .CliBase import CliBase | ||||
| @ -62,8 +65,6 @@ class ZfsCheck(CliBase): | ||||
|                     print("{}\t{}\t{}".format(file, block, hash)) | ||||
|                     sys.stdout.flush() #important, to generate SIGPIPES on ssh disconnect | ||||
|  | ||||
|         # except BrokenPipeError: | ||||
|         #     output_redir() | ||||
|  | ||||
|         finally: | ||||
|             snapshot.unmount() | ||||
| @ -89,7 +90,7 @@ class ZfsCheck(CliBase): | ||||
|         start_time = time.time() | ||||
|         while time.time() - start_time < 10: | ||||
|             for location in locations: | ||||
|                 if pathlib.Path(location).is_block_device(): | ||||
|                 if os.path.exists(location): | ||||
|                     return location | ||||
|  | ||||
|                 # fake it in testmode | ||||
| @ -116,15 +117,12 @@ class ZfsCheck(CliBase): | ||||
|                     print("{}\t{}".format(block, hash)) | ||||
|                     sys.stdout.flush() #important, to generate SIGPIPES on ssh disconnect | ||||
|  | ||||
|         except BrokenPipeError: | ||||
|             output_redir() | ||||
|  | ||||
|         finally: | ||||
|             self.deacitvate_volume_snapshot(snapshot) | ||||
|  | ||||
|     def run(self): | ||||
|  | ||||
|  | ||||
|         snapshot = self.node.get_dataset(self.args.snapshot) | ||||
|  | ||||
|         if not snapshot.exists: | ||||
| @ -150,6 +148,8 @@ class ZfsCheck(CliBase): | ||||
| def cli(): | ||||
|     import sys | ||||
|  | ||||
|     signal(SIGPIPE, output_redir) | ||||
|  | ||||
|     sys.exit(ZfsCheck(sys.argv[1:], False).run()) | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -64,7 +64,7 @@ def block_hash_tree(start_path, count=10000, bs=4096): | ||||
|     try: | ||||
|         for (dirpath, dirnames, filenames) in os.walk(".", onerror=walkerror): | ||||
|             for f in filenames: | ||||
|                 file_path=os.path.join(dirpath, f) | ||||
|                 file_path=os.path.join(dirpath, f)[2:] | ||||
|  | ||||
|                 if (not os.path.islink(file_path)) and os.path.isfile(file_path): | ||||
|                     for (chunk_nr, hash) in block_hash(file_path, count, bs): | ||||
|  | ||||
		Reference in New Issue
	
	Block a user