Line |
Branch |
Exec |
Source |
1 |
|
|
/** |
2 |
|
|
* This file is part of the CernVM File System. |
3 |
|
|
*/ |
4 |
|
|
|
5 |
|
|
#include "cvmfs_config.h" |
6 |
|
|
#include "publish/repository.h" |
7 |
|
|
|
8 |
|
|
#include <vector> |
9 |
|
|
|
10 |
|
|
#include "history_sqlite.h" |
11 |
|
|
#include "publish/except.h" |
12 |
|
|
#include "sanitizer.h" |
13 |
|
|
|
14 |
|
|
namespace publish { |
15 |
|
|
|
16 |
|
✗ |
void Publisher::CheckTagName(const std::string &name) { |
17 |
|
✗ |
if (name.empty()) throw EPublish("the empty string is not a valid tag name"); |
18 |
|
✗ |
if (name == "trunk") |
19 |
|
✗ |
throw EPublish("'trunk' is not allowed as a custom tag name"); |
20 |
|
✗ |
if (name == "trunk-previous") |
21 |
|
✗ |
throw EPublish("'trunk-previous' is not allowed as a custom tag name"); |
22 |
|
✗ |
if (!sanitizer::TagSanitizer().IsValid(name)) |
23 |
|
✗ |
throw EPublish("invalid tag name: " + name); |
24 |
|
|
} |
25 |
|
|
|
26 |
|
|
|
27 |
|
✗ |
void Publisher::EditTags(const std::vector<history::History::Tag> &add_tags, |
28 |
|
|
const std::vector<std::string> &rm_tags) |
29 |
|
|
{ |
30 |
|
✗ |
if (!in_transaction_.IsSet()) |
31 |
|
✗ |
throw EPublish("cannot edit tags outside transaction"); |
32 |
|
|
|
33 |
|
✗ |
for (unsigned i = 0; i < add_tags.size(); ++i) { |
34 |
|
✗ |
std::string name = add_tags[i].name; |
35 |
|
✗ |
CheckTagName(name); |
36 |
|
✗ |
history_->Insert(add_tags[i]); |
37 |
|
|
} |
38 |
|
|
|
39 |
|
✗ |
for (unsigned i = 0; i < rm_tags.size(); ++i) { |
40 |
|
✗ |
std::string name = rm_tags[i]; |
41 |
|
✗ |
CheckTagName(name); |
42 |
|
✗ |
if (history_->Exists(name)) { |
43 |
|
✗ |
bool retval = history_->Remove(name); |
44 |
|
✗ |
if (!retval) throw EPublish("cannot remove tag " + name); |
45 |
|
|
} |
46 |
|
|
} |
47 |
|
|
|
48 |
|
✗ |
PushHistory(); |
49 |
|
|
|
50 |
|
|
// TODO(jblomer): virtual catalog |
51 |
|
|
} |
52 |
|
|
|
53 |
|
|
} // namespace publish |
54 |
|
|
|