tvl-depot/src/libstore/download.hh
Eelco Dolstra e9c50064b5 Add an HTTP binary cache store
Allowing stuff like

  NIX_REMOTE=https://cache.nixos.org nix-store -qR /nix/store/x1p1gl3a4kkz5ci0nfbayjqlqmczp1kq-geeqie-1.1

or

  NIX_REMOTE=https://cache.nixos.org nix-store --export /nix/store/x1p1gl3a4kkz5ci0nfbayjqlqmczp1kq-geeqie-1.1 | nix-store --import
2016-02-29 18:15:20 +01:00

47 lines
798 B
C++

#pragma once
#include "types.hh"
#include <string>
namespace nix {
struct DownloadOptions
{
string expectedETag;
bool verifyTLS{true};
enum { yes, no, automatic } showProgress{yes};
bool head{false};
};
struct DownloadResult
{
bool cached;
string data, etag;
};
class Store;
struct Downloader
{
virtual DownloadResult download(string url, const DownloadOptions & options) = 0;
Path downloadCached(ref<Store> store, const string & url, bool unpack);
enum Error { NotFound, Forbidden, Misc };
};
ref<Downloader> makeDownloader();
class DownloadError : public Error
{
public:
Downloader::Error error;
DownloadError(Downloader::Error error, const FormatOrString & fs)
: Error(fs), error(error)
{ }
};
bool isUri(const string & s);
}