aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-08-26 17:28:09 +0200
committerStefan Boberg <[email protected]>2021-08-26 17:28:09 +0200
commitd5d7b29be5454aaa2fa17bf71c65adb2754b71fb (patch)
tree41d306b66b96439acd5af90ca81ff7270972e364
parentAdded missing lock to side channel InsertChunk() implementation (diff)
downloadzen-d5d7b29be5454aaa2fa17bf71c65adb2754b71fb.tar.xz
zen-d5d7b29be5454aaa2fa17bf71c65adb2754b71fb.zip
Removed FileCasImpl (unused)
-rw-r--r--zenstore/filecas.cpp84
1 files changed, 4 insertions, 80 deletions
diff --git a/zenstore/filecas.cpp b/zenstore/filecas.cpp
index 845206741..7465e5182 100644
--- a/zenstore/filecas.cpp
+++ b/zenstore/filecas.cpp
@@ -17,13 +17,10 @@
#include <functional>
#include <unordered_map>
-// clang-format off
#include <zencore/prewindows.h>
struct IUnknown; // Workaround for "combaseapi.h(229): error C2187: syntax error: 'identifier' was unexpected here" when using /permissive-
#include <atlfile.h>
-#include <ShlObj.h> // Used for getting My Documents for default CAS
-#pragma comment(lib, "shell32.lib")
#include <zencore/postwindows.h>
// clang-format on
@@ -100,14 +97,12 @@ FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash)
{
CAtlFile PayloadFile;
- HRESULT hRes = PayloadFile.Create(ShardedPath.c_str(), GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING);
-
- if (SUCCEEDED(hRes))
+ if (HRESULT hRes = PayloadFile.Create(ShardedPath.c_str(), GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING); SUCCEEDED(hRes))
{
- // If we succeeded in opening the file then we don't need to do anything else because it already exists and should contain
- // the content we were about to insert
+ // If we succeeded in opening the target file then we don't need to do anything else because it already exists
+ // and should contain the content we were about to insert
- // We do need to ensure the file goes away on close, however
+ // We do need to ensure the source file goes away on close, however
DeletePayloadFileOnClose();
@@ -362,75 +357,4 @@ FileCasStrategy::GarbageCollect(GcContext& GcCtx)
{
}
-/**
- * Straightforward file-per-chunk CAS store implementation
- */
-class FileCasImpl : public CasStore
-{
-public:
- FileCasImpl() : m_Strategy(m_Config, m_Stats) {}
- virtual ~FileCasImpl() = default;
-
- void PickDefaultDirectory()
- {
- if (m_Config.RootDirectory.empty())
- {
- // Pick sensible default
-
- WCHAR myDocumentsDir[MAX_PATH];
- HRESULT hRes = SHGetFolderPathW(NULL,
- CSIDL_PERSONAL /* My Documents */,
- NULL,
- SHGFP_TYPE_CURRENT,
- /* out */ myDocumentsDir);
-
- if (SUCCEEDED(hRes))
- {
- wcscat_s(myDocumentsDir, L"\\zen\\DefaultCAS");
-
- m_Config.RootDirectory = myDocumentsDir;
- }
- }
- }
-
- virtual void Initialize(const CasStoreConfiguration& InConfig) override
- {
- m_Config = InConfig;
-
- if (m_Config.RootDirectory.empty())
- {
- PickDefaultDirectory();
- }
-
- // Ensure root directory exists - create if it doesn't exist already
-
- std::filesystem::create_directories(m_Config.RootDirectory);
-
- std::filesystem::path filepath = m_Config.RootDirectory;
- filepath /= ".cas_root";
-
- CAtlFile marker;
- HRESULT hRes = marker.Create(filepath.c_str(), GENERIC_READ, 0, OPEN_EXISTING);
-
- if (FAILED(hRes))
- {
- ExtendableStringBuilder<128> manifest;
- manifest.Append("CAS_ROOT");
- hRes = marker.Create(filepath.c_str(), GENERIC_WRITE, 0, CREATE_ALWAYS);
-
- if (SUCCEEDED(hRes))
- marker.Write(manifest.c_str(), (DWORD)manifest.Size());
- }
- }
-
- virtual CasStore::InsertResult InsertChunk(IoBuffer Chunk, const IoHash& chunkHash) override
- {
- return m_Strategy.InsertChunk(Chunk, chunkHash);
- }
- virtual IoBuffer FindChunk(const IoHash& chunkHash) override { return m_Strategy.FindChunk(chunkHash); }
-
-private:
- FileCasStrategy m_Strategy;
-};
-
} // namespace zen