From 8ba2c70291ebff7b4b69956b667d84812e53afde Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Fri, 9 Nov 2012 13:34:17 +0100 Subject: [PATCH] add http/https support to verify_remote_fileid() Signed-off-by: Tobias Ulmer --- local/e2tool.lua | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/local/e2tool.lua b/local/e2tool.lua index 2d426a5..e608970 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -43,6 +43,8 @@ local e2option = require("e2option") local generic_git = require("generic_git") local policy = require("policy") local strict = require("strict") +local transport = require("transport") +local cache = require("cache") -- Information gathering and inquiry -- @@ -1927,9 +1929,28 @@ local function verify_remote_fileid(info, file, fileid) if not remote_fileid then return false, e:cat(re) end + elseif u.transport == "http" or u.transport == "https" then + local ce, re = cache.ce_by_server(info.cache, file.server) + if not ce then + return false, e:cat(re) + end + + local tmpfile = e2lib.mktempfile() + rc, re = transport.fetch_file(ce.remote_url, file.location, + e2lib.dirname(tmpfile), e2lib.basename(tmpfile)) + if not rc then + return false, e:cat(re) + end + + remote_fileid, re = e2lib.sha1sum(tmpfile) + if not remote_fileid then + return false, e:cat(re) + end + + e2lib.rmtempfile(tmpfile) else - return false, err.new("transport not supported: %s", - u.transport) + return false, err.new("verify remote fileid: transport not supported: %s", + u.transport) end if fileid ~= remote_fileid then return false, err.new( -- 2.39.5