Skip to content

Commit

Permalink
add buffsize option
Browse files Browse the repository at this point in the history
  • Loading branch information
abbbi committed Sep 6, 2023
1 parent b3688cd commit ed1641a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Version 1.9.41
---------
* virtnbdrestore: add Option -B to allow changing default buffer size
duing verify to speed up process.

Version 1.9.40
---------
Expand Down
13 changes: 11 additions & 2 deletions virtnbdrestore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import os
import io
import zlib
import sys
import tempfile
Expand Down Expand Up @@ -81,6 +82,7 @@ def verify(args: Namespace, dataFiles: List[str]) -> bool:
args.disk
):
continue
logging.debug("Using buffer size: %s", args.buffsize)
logging.info("Computing checksum for: %s", dataFile)

sourceFile = dataFile
Expand All @@ -89,10 +91,10 @@ def verify(args: Namespace, dataFiles: List[str]) -> bool:

with output.openfile(sourceFile, "rb") as vfh:
adler = 1
data = vfh.read(4096)
data = vfh.read(args.buffsize)
while data:
adler = zlib.adler32(data, adler)
data = vfh.read(4096)
data = vfh.read(args.buffsize)

chksumFile = f"{sourceFile}.chksum"
logging.info("Checksum result: %s", adler)
Expand Down Expand Up @@ -646,6 +648,13 @@ def main() -> None:
type=str,
help="Define restored domain with specified name",
)
opt.add_argument(
"-B",
"--buffsize",
default=io.DEFAULT_BUFFER_SIZE,
type=int,
help="Buffer size to use during verify (default: %(default)s)",
)
remopt = parser.add_argument_group("Remote Restore options")
argopt.addRemoteArgs(remopt)
logopt = parser.add_argument_group("Logging options")
Expand Down

0 comments on commit ed1641a

Please sign in to comment.