1 |
douglas |
514 |
// Share |
2 |
|
|
// |
3 |
|
|
// Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// $Id$ |
6 |
|
|
|
7 |
douglas |
558 |
#include <menes/cxx/standard.hh> |
8 |
douglas |
514 |
|
9 |
douglas |
516 |
#include "Share.hpp" |
10 |
|
|
|
11 |
douglas |
555 |
Share::Share(const _R<Connector>& connector, const api::Address& host, const cse::String& share) : connector(connector), host(host), share(share) |
12 |
douglas |
514 |
{ |
13 |
douglas |
535 |
cse::String address, port; |
14 |
douglas |
514 |
|
15 |
douglas |
535 |
host.ToString(address, port); |
16 |
|
|
|
17 |
douglas |
542 |
api::Path host_(shares.GetChild(address)); |
18 |
douglas |
535 |
|
19 |
douglas |
514 |
if (!host_.Exists()) |
20 |
douglas |
529 |
host_.CreateDirectory(); |
21 |
douglas |
514 |
|
22 |
|
|
path = host_.GetChild(share); |
23 |
|
|
|
24 |
|
|
if (!path.Exists()) |
25 |
douglas |
529 |
path.CreateDirectory(); |
26 |
douglas |
514 |
} |
27 |
|
|
|
28 |
douglas |
534 |
Share::~Share() |
29 |
douglas |
514 |
{ |
30 |
douglas |
555 |
_R<dbi::Connection> connection(connector->Connect()); |
31 |
|
|
|
32 |
douglas |
514 |
connection->Parse(_B("UPDATE files SET live = FALSE WHERE root = ?"))->Execute(path.GetPath()); |
33 |
douglas |
555 |
connector->Release(connection); |
34 |
douglas |
514 |
} |
35 |
douglas |
542 |
|
36 |
|
|
api::Path Share::shares(_B("Shares")); |