From 2ce4042180654f51ef2174417c5455b223f101c1 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Thu, 5 Jan 2012 21:23:51 +0100 Subject: [PATCH] rpc._PrepareFileUpload: Use FileStatHelper Use fstat(2) on the file handle instead of doing a separate stat(2). Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/rpc.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/rpc.py b/lib/rpc.py index c9ac36fe0..3b007509d 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -30,7 +30,6 @@ # if they need to start using instance attributes # R0904: Too many public methods -import os import logging import zlib import base64 @@ -520,9 +519,9 @@ def _PrepareFileUpload(getents_fn, filename): """Loads a file and prepares it for an upload to nodes. """ - # TODO: Use ReadFile(preread=...) and os.fstat - data = _Compress(utils.ReadFile(filename)) - st = os.stat(filename) + statcb = utils.FileStatHelper() + data = _Compress(utils.ReadFile(filename, preread=statcb)) + st = statcb.st if getents_fn is None: getents_fn = runtime.GetEnts -- GitLab