MCPcopy Create free account
hub / github.com/Snapchat/Valdi / store

Method store

valdi/src/valdi/runtime/Resources/DiskCacheImpl.cpp:59–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59Result<Void> DiskCacheImpl::store(const Path& path, const BytesView& bytes) {
60 auto resolvedPath = resolveAbsolutePath(path, false);
61 if (!resolvedPath) {
62 return resolvedPath.moveError();
63 }
64
65 auto filePath = resolvedPath.moveValue();
66
67 if (filePath.getComponents().size() > 1) {
68 auto directoryPath = filePath.removingLastComponent();
69 if (!DiskUtils::isDirectory(directoryPath) && !DiskUtils::makeDirectory(directoryPath, true)) {
70 return Error(STRING_FORMAT("Failed to create directories to store file at {}", filePath.toString()));
71 }
72 }
73
74 return DiskUtils::store(filePath, bytes);
75}
76
77Ref<IDiskCache> DiskCacheImpl::scopedCache(const Path& subfolder, bool allowsReadOutsideOfScope) const {
78 auto result = resolveAbsolutePath(subfolder, false);

Callers

nothing calls this directly

Calls 6

isDirectoryFunction · 0.85
storeFunction · 0.85
toStringMethod · 0.65
ErrorInterface · 0.50
sizeMethod · 0.45
removingLastComponentMethod · 0.45

Tested by

no test coverage detected