summaryrefslogtreecommitdiff
path: root/src/repoList.cpp
blob: e3dbb0cf177ff80a39cb0c1472903a61811bee5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "repoList.h"
#include "repo.h"
#include <Ice/ObjectAdapter.h>
#include <Ice/Properties.h>

#include <compileTimeFormatter.h>

GitFS::RepoList::RepoList(Ice::PropertiesPtr && p) : properties(std::move(p)) { }

AdHocFormatter(RepoPropertyName, "GitFS.%?.%?");

NetFS::VolumePrxPtr
GitFS::RepoList::connect(const ::std::string volume, const ::std::string auth, const ::Ice::Current & ice)
{
	if (volume.empty()) {
		throw NetFS::ConfigError();
	}

	const auto propReader = std::bind(&Ice::Properties::getProperty, properties,
			std::bind((std::string(*)(const std::string_view &, const std::string_view &))(&RepoPropertyName::get),
					volume, std::placeholders::_1));

	if (propReader("gitdir").empty()) {
		throw NetFS::ConfigError();
	}
	if (propReader("authkey") != auth) {
		throw NetFS::AuthError();
	}
	return Ice::uncheckedCast<NetFS::VolumePrx>(ice.adapter->addWithUUID(std::make_shared<Repo>(propReader)));
}