Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
scan_blacklist.hpp
Go to the documentation of this file.
1#pragma once
2
3// Scan blacklist companion to HostScanCache.
4//
5// When a plugin crashes the scanner, the out-of-process scan worker records
6// the plugin path + its (mtime, size) pair here. Subsequent scans skip
7// blacklisted entries entirely so one bad plugin can't loop the entire scan
8// on every startup.
9//
10// Format is a newline-delimited text file — one entry per line — so a
11// user can hand-edit if they want to retry a blacklisted plugin. Lines
12// starting with `#` are comments.
13
14#include <cstdint>
15#include <optional>
16#include <string>
17#include <unordered_map>
18#include <vector>
19
20namespace pulp::host {
21
23 int64_t mtime = 0;
24 int64_t size = 0;
25 std::string reason;
26};
27
29public:
34 std::optional<BlacklistEntry> get(const std::string& path) const;
35
38 void blacklist(const std::string& path, std::string reason);
39
42 void clear(const std::string& path) { entries_.erase(path); }
43
44 std::size_t size() const { return entries_.size(); }
45 bool is_blacklisted(const std::string& path) const {
46 return get(path).has_value();
47 }
48
50 std::string to_text() const;
51
55 bool from_text(const std::string& text);
56
57 bool save_to(const std::string& file_path) const;
58 bool load_from(const std::string& file_path);
59
60 const std::unordered_map<std::string, BlacklistEntry>& entries() const {
61 return entries_;
62 }
63
64private:
65 std::unordered_map<std::string, BlacklistEntry> entries_;
66};
67
68} // namespace pulp::host
Definition scan_blacklist.hpp:28
std::optional< BlacklistEntry > get(const std::string &path) const
Return the blacklist entry for path if one exists AND matches the current file stamp.
void clear(const std::string &path)
Unconditionally remove path from the blacklist.
Definition scan_blacklist.hpp:42
std::string to_text() const
Serialize to the plain-text format described at the top.
bool load_from(const std::string &file_path)
std::size_t size() const
Definition scan_blacklist.hpp:44
const std::unordered_map< std::string, BlacklistEntry > & entries() const
Definition scan_blacklist.hpp:60
bool save_to(const std::string &file_path) const
void blacklist(const std::string &path, std::string reason)
Record that scanning path failed.
bool from_text(const std::string &text)
Load from the plain-text format.
bool is_blacklisted(const std::string &path) const
Definition scan_blacklist.hpp:45
Bounded event contracts shared by host ingress and graph-authored nodes.
Definition anticipation_eligibility.hpp:9
Definition scan_blacklist.hpp:22
std::string reason
free-text explanation (e.g. "SIGSEGV", "timeout")
Definition scan_blacklist.hpp:25
int64_t mtime
Definition scan_blacklist.hpp:23
int64_t size
Definition scan_blacklist.hpp:24