Commit 2ce40421 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

rpc._PrepareFileUpload: Use FileStatHelper



Use fstat(2) on the file handle instead of doing a separate stat(2).
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 2635bb04
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment