MCPcopy Create free account
hub / github.com/clangen/musikcube / PruneTranscodeCache

Method PruneTranscodeCache

src/plugins/server/Transcoder.cpp:131–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131void Transcoder::PruneTranscodeCache(Context& context) {
132 std::map<time_t, fs::path> sorted;
133
134 iterateTranscodeCache(context, [&sorted](fs::path p) {
135 sorted[lastWriteTime(p)] = p;
136 });
137
138 int maxSize = context.prefs->GetInt(
139 prefs::transcoder_cache_count.c_str(),
140 defaults::transcoder_cache_count);
141
142 int extra = (int) sorted.size() - (maxSize - 1);
143 auto it = sorted.begin();
144 while (extra > 0 && it != sorted.end()) {
145 auto p = it->second;
146 std::error_code ec;
147 if (fs::remove(p, ec)) {
148 --extra;
149 }
150 ++it;
151 }
152}
153
154static void getTempAndFinalFilename(
155 Context& context,

Callers

nothing calls this directly

Calls 6

iterateTranscodeCacheFunction · 0.85
lastWriteTimeFunction · 0.85
GetIntMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected