• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

paticcaa / pain / 17371184884

01 Sep 2025 07:48AM UTC coverage: 56.221% (+0.3%) from 55.963%
17371184884

Pull #7

github

web-flow
Merge 696a4eeb7 into 8cf6c54ed
Pull Request #7: add version for op

1394 of 3306 branches covered (42.17%)

Branch coverage included in aggregate %.

28 of 34 new or added lines in 7 files covered. (82.35%)

1629 of 2071 relevant lines covered (78.66%)

430.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

54.69
/src/deva/deva.cc
1
#include "deva/deva.h"
2
#include <pain/base/plog.h>
3
#include <pain/base/uuid.h>
4
#include "deva/macro.h"
5

6
#define DEVA_METHOD(name)                                                                                              \
7
    Status Deva::name([[maybe_unused]] int32_t version,                                                                \
8
                      [[maybe_unused]] const pain::proto::deva::store::name##Request* request,                         \
9
                      [[maybe_unused]] pain::proto::deva::store::name##Response* response,                             \
10
                      [[maybe_unused]] int64_t index)
11

12
namespace pain::deva {
13

14
Status Deva::create(const std::string& path, const UUID& id, FileType type) {
67✔
15
    SPAN(span);
335!
16
    PLOG_DEBUG(("desc", "create")("path", path)("id", id.str())("type", type));
67✔
17
    // get parent
18
    std::filesystem::path file_path(path);
67!
19
    auto dir = file_path.parent_path();
67!
20
    auto filename = file_path.filename();
67!
21
    auto file_type = FileType::kFile;
67✔
22
    UUID parent_dir_uuid;
67✔
23
    auto status = _namespace.lookup(dir.c_str(), &parent_dir_uuid, &file_type);
66!
24
    if (!status.ok()) {
66✔
25
        return status;
41!
26
    }
27

28
    if (file_type != FileType::kDirectory) {
24!
29
        return Status(EINVAL, fmt::format("{} is not a directory", dir.c_str()));
×
30
    }
31

32
    UUID file_uuid(id.high(), id.low());
24✔
33
    status = _namespace.create(parent_dir_uuid, filename, type, file_uuid);
24!
34
    if (!status.ok()) {
24!
35
        return status;
×
36
    }
37

38
    return Status::OK();
24✔
39
}
199✔
40

41
DEVA_METHOD(CreateFile) {
33✔
42
    SPAN(span);
165!
43
    PLOG_DEBUG(("desc", "create_file")("version", version)("index", index)("request", request->DebugString()));
33✔
44
    auto& path = request->path();
33!
45
    auto& file_id = request->file_id();
33!
46
    UUID file_uuid(file_id.high(), file_id.low());
33!
47
    auto status = create(path, file_uuid, FileType::kFile);
33!
48
    if (!status.ok()) {
33✔
49
        return status;
21!
50
    }
51
    auto file_info = response->mutable_file_info();
12!
52
    file_info->mutable_file_id()->set_high(file_uuid.high());
12!
53
    file_info->mutable_file_id()->set_low(file_uuid.low());
12!
54
    file_info->set_type(pain::proto::FileType::FILE_TYPE_FILE);
12!
55
    file_info->set_size(0);
12!
56
    file_info->set_atime(request->atime());
12!
57
    file_info->set_mtime(request->mtime());
12!
58
    file_info->set_ctime(request->ctime());
12!
59
    file_info->set_mode(request->mode());
12!
60
    file_info->set_uid(request->uid());
12!
61
    file_info->set_gid(request->gid());
12!
62
    _file_infos[file_uuid] = *file_info;
12!
63
    return Status::OK();
12✔
64
}
99✔
65

66
DEVA_METHOD(CreateDir) {
34✔
67
    SPAN(span);
169!
68
    PLOG_DEBUG(("desc", "create_dir")("version", version)("index", index)("request", request->DebugString()));
34✔
69
    auto& path = request->path();
34!
70
    auto& dir_id = request->dir_id();
34!
71
    UUID dir_uuid(dir_id.high(), dir_id.low());
34!
72
    auto status = create(path, dir_uuid, FileType::kDirectory);
34!
73
    if (!status.ok()) {
34✔
74
        return status;
22!
75
    }
76
    auto file_info = response->mutable_file_info();
12!
77
    file_info->mutable_file_id()->set_high(dir_uuid.high());
12!
78
    file_info->mutable_file_id()->set_low(dir_uuid.low());
12!
79
    file_info->set_type(pain::proto::FileType::FILE_TYPE_DIRECTORY);
12!
80
    file_info->set_size(0);
12!
81
    file_info->set_atime(request->atime());
12!
82
    file_info->set_mtime(request->mtime());
12!
83
    file_info->set_ctime(request->ctime());
12!
84
    file_info->set_mode(request->mode());
12!
85
    file_info->set_uid(request->uid());
12!
86
    file_info->set_gid(request->gid());
12!
87
    _file_infos[dir_uuid] = *file_info;
12!
88
    return Status::OK();
12✔
89
}
102✔
90

91
DEVA_METHOD(ReadDir) {
1✔
92
    SPAN(span);
5!
93
    PLOG_DEBUG(("desc", "read_dir")("version", version)("index", index)("request", request->DebugString()));
1✔
94
    auto& path = request->path();
1!
95
    UUID parent_dir_uuid;
1✔
96
    FileType file_type = FileType::kNone;
1✔
97
    auto status = _namespace.lookup(path.c_str(), &parent_dir_uuid, &file_type);
1!
98
    if (!status.ok()) {
1!
99
        return status;
×
100
    }
101
    if (file_type != FileType::kDirectory) {
1!
102
        return Status(EINVAL, fmt::format("{} is not a directory", path.c_str()));
×
103
    }
104
    std::list<DirEntry> entries;
1✔
105
    _namespace.list(parent_dir_uuid, &entries);
1!
106
    for (auto& entry : entries) {
21✔
107
        auto dir_entry = response->add_entries();
20!
108
        dir_entry->mutable_file_id()->set_high(entry.inode.high());
20!
109
        dir_entry->mutable_file_id()->set_low(entry.inode.low());
20!
110
        dir_entry->set_type(static_cast<pain::proto::FileType>(entry.type));
20!
111
        dir_entry->set_name(std::move(entry.name));
20✔
112
    }
113
    return Status::OK();
1✔
114
}
3✔
115

116
DEVA_METHOD(RemoveFile) {
×
117
    SPAN(span);
×
NEW
118
    PLOG_INFO(("desc", "remove_file")("version", version)("index", index));
×
119
    return Status::OK();
×
120
}
×
121

122
DEVA_METHOD(SealFile) {
×
123
    SPAN(span);
×
NEW
124
    PLOG_INFO(("desc", "seal_file")("version", version)("index", index));
×
125
    return Status::OK();
×
126
}
×
127

128
DEVA_METHOD(CreateChunk) {
×
129
    SPAN(span);
×
NEW
130
    PLOG_INFO(("desc", "remove")("version", version)("index", index));
×
131
    return Status::OK();
×
132
}
×
133

134
DEVA_METHOD(CheckInChunk) {
×
135
    SPAN(span);
×
NEW
136
    PLOG_INFO(("desc", "seal")("version", version)("index", index));
×
137
    return Status::OK();
×
138
}
×
139

140
DEVA_METHOD(SealChunk) {
×
141
    SPAN(span);
×
NEW
142
    PLOG_INFO(("desc", "create_chunk")("version", version)("index", index));
×
143
    return Status::OK();
×
144
}
×
145

146
DEVA_METHOD(SealAndNewChunk) {
×
147
    SPAN(span);
×
NEW
148
    PLOG_INFO(("desc", "remove_chunk")("version", version)("index", index));
×
149
    return Status::OK();
×
150
}
×
151

152
Status Deva::save_snapshot(std::string_view path, std::vector<std::string>* files) {
×
153
    std::ignore = path;
×
154
    std::ignore = files;
×
155
    return Status::OK();
×
156
}
157

158
Status Deva::load_snapshot(std::string_view path) {
×
159
    std::ignore = path;
×
160
    return Status::OK();
×
161
}
162

163
} // namespace pain::deva
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc