MCPcopy Create free account
hub / github.com/ByConity/ByConity / writeFile

Method writeFile

src/Disks/DiskCacheWrapper.cpp:181–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179}
180
181std::unique_ptr<WriteBufferFromFileBase>
182DiskCacheWrapper::writeFile(const String & path, const WriteSettings& settings)
183{
184 if (!cache_file_predicate(path))
185 return DiskDecorator::writeFile(path, settings);
186
187 LOG_DEBUG(log, "Write file {} to cache", backQuote(path));
188
189 auto dir_path = directoryPath(path);
190 if (!cache_disk->exists(dir_path))
191 cache_disk->createDirectories(dir_path);
192
193 return std::make_unique<CompletionAwareWriteBuffer>(
194 cache_disk->writeFile(path, settings),
195 [this, path, settings]()
196 {
197 /// Copy file from cache to actual disk when cached buffer is finalized.
198 auto src_buffer = cache_disk->readFile(path, ReadSettings().initializeReadSettings(settings.buffer_size));
199 auto dst_buffer = DiskDecorator::writeFile(path, settings);
200 copyData(*src_buffer, *dst_buffer);
201 dst_buffer->finalize();
202 });
203}
204
205void DiskCacheWrapper::clearDirectory(const String & path)
206{

Callers 1

readFileMethod · 0.45

Calls 9

backQuoteFunction · 0.85
directoryPathFunction · 0.85
ReadSettingsClass · 0.85
copyDataFunction · 0.50
existsMethod · 0.45
createDirectoriesMethod · 0.45
readFileMethod · 0.45
finalizeMethod · 0.45

Tested by

no test coverage detected