aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/projectstore/fileremoteprojectstore.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2024-03-22 10:12:42 +0100
committerGitHub Enterprise <[email protected]>2024-03-22 10:12:42 +0100
commitf45f810fb1961d1cc5dfe57569010f623193b641 (patch)
treebe6e2fb949afa6f1cc302a02f8f29d771ff24bc7 /src/zenserver/projectstore/fileremoteprojectstore.cpp
parentdisable partial getcachechunk responses (#19) (diff)
downloadzen-f45f810fb1961d1cc5dfe57569010f623193b641.tar.xz
zen-f45f810fb1961d1cc5dfe57569010f623193b641.zip
check existance of reused blocks (#18)
* Add HasAttachments to RemoteProjectStore so we can query if attachment blocks actually exist * use individual requests for compressed blob check in Jupiter * remove weird 1000.5 to 1000.0 when converting seconds to milliseconds
Diffstat (limited to 'src/zenserver/projectstore/fileremoteprojectstore.cpp')
-rw-r--r--src/zenserver/projectstore/fileremoteprojectstore.cpp37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/zenserver/projectstore/fileremoteprojectstore.cpp b/src/zenserver/projectstore/fileremoteprojectstore.cpp
index defa7bf80..4248bbf2a 100644
--- a/src/zenserver/projectstore/fileremoteprojectstore.cpp
+++ b/src/zenserver/projectstore/fileremoteprojectstore.cpp
@@ -84,7 +84,7 @@ public:
Result.ErrorCode = gsl::narrow<int32_t>(HttpResponseCode::InternalServerError);
Result.Reason = fmt::format("Failed saving oplog container to '{}'. Reason: {}", ContainerPath, Ex.what());
}
- Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.500;
+ Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.0;
return Result;
}
@@ -114,7 +114,7 @@ public:
Result.Reason = fmt::format("Failed saving oplog attachment to '{}'. Reason: {}", ChunkPath, Ex.what());
}
}
- Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.500;
+ Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.0;
return Result;
}
@@ -128,12 +128,12 @@ public:
SaveAttachmentResult ChunkResult = SaveAttachment(Compressed.GetCompressed(), Compressed.DecodeRawHash());
if (ChunkResult.ErrorCode)
{
- ChunkResult.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.500;
+ ChunkResult.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.0;
return SaveAttachmentsResult{ChunkResult};
}
}
SaveAttachmentsResult Result;
- Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.500;
+ Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.0;
return Result;
}
@@ -148,6 +148,23 @@ public:
}
return LoadContainer(m_OptionalBaseName);
}
+
+ virtual HasAttachmentsResult HasAttachments(const std::span<IoHash> RawHashes) override
+ {
+ Stopwatch Timer;
+ HasAttachmentsResult Result;
+ for (const IoHash& RawHash : RawHashes)
+ {
+ std::filesystem::path ChunkPath = GetAttachmentPath(RawHash);
+ if (!std::filesystem::is_regular_file(ChunkPath))
+ {
+ Result.Needs.insert(RawHash);
+ }
+ }
+ Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.0;
+ return Result;
+ }
+
virtual LoadAttachmentResult LoadAttachment(const IoHash& RawHash) override
{
Stopwatch Timer;
@@ -157,7 +174,7 @@ public:
{
Result.ErrorCode = gsl::narrow<int>(HttpResponseCode::NotFound);
Result.Reason = fmt::format("Failed loading oplog attachment from '{}'. Reason: 'The file does not exist'", ChunkPath.string());
- Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.500;
+ Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.0;
return Result;
}
{
@@ -165,7 +182,7 @@ public:
ChunkFile.Open(ChunkPath, BasicFile::Mode::kRead);
Result.Bytes = ChunkFile.ReadAll();
}
- Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.500;
+ Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.0;
return Result;
}
@@ -178,7 +195,7 @@ public:
LoadAttachmentResult ChunkResult = LoadAttachment(Hash);
if (ChunkResult.ErrorCode)
{
- ChunkResult.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.500;
+ ChunkResult.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.0;
return LoadAttachmentsResult{ChunkResult};
}
ZEN_DEBUG("Loaded attachment in {}", NiceTimeSpanMs(static_cast<uint64_t>(ChunkResult.ElapsedSeconds * 1000)));
@@ -199,7 +216,7 @@ private:
{
Result.ErrorCode = gsl::narrow<int>(HttpResponseCode::NotFound);
Result.Reason = fmt::format("Failed loading oplog container from '{}'. Reason: 'The file does not exist'", SourcePath.string());
- Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.500;
+ Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.0;
return Result;
}
IoBuffer ContainerPayload;
@@ -213,10 +230,10 @@ private:
{
Result.ErrorCode = gsl::narrow<int32_t>(HttpResponseCode::InternalServerError);
Result.Reason = fmt::format("The file {} is not formatted as a compact binary object", SourcePath.string());
- Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.500;
+ Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.0;
return Result;
}
- Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.500;
+ Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.0;
return Result;
}