Audacity 3.2.0
RemoteProjectSnapshot.cpp
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 RemoteProjectSnapshot.cpp
7
8 Dmitry Vedenko
9
10**********************************************************************/
12
13#include <algorithm>
14#include <unordered_set>
15
16#include <wx/datetime.h>
17
19
20#include "CodeConversions.h"
21#include "Internat.h"
22#include "MemoryX.h"
23#include "StringUtils.h"
24
25#include "IResponse.h"
26#include "NetworkManager.h"
27#include "Request.h"
28
29#include "WavPackCompressor.h"
30
32{
33namespace
34{
35std::vector<std::string> ListAttachedDatabases()
36{
38 auto statement = db->CreateStatement("PRAGMA database_list");
39 auto result = statement->Prepare().Run();
40
41 std::vector<std::string> attachedDBs;
42
43 for (auto row : result)
44 {
45 std::string dbName;
46
47 if (!row.Get(1, dbName))
48 continue;
49
50 if (dbName == "main" || dbName == "temp")
51 continue;
52
53 attachedDBs.push_back(std::move(dbName));
54 }
55
56 return attachedDBs;
57}
58} // namespace
59
61 Tag, ProjectInfo projectInfo, SnapshotInfo snapshotInfo, std::string path,
62 RemoteProjectSnapshotStateCallback callback, bool downloadDetached)
63 : mSnapshotDBName { std::string("s_") + projectInfo.Id }
64 , mProjectInfo { std::move(projectInfo) }
65 , mSnapshotInfo { std::move(snapshotInfo) }
66 , mPath { std::move(path) }
67 , mCallback { std::move(callback) }
68 , mDownloadDetached { downloadDetached }
69{
71 // RemoteProjectSnapshot always receives a path to the database
72 // that has AudacityProject schema installed, even if it's a detached
73 // or was deleted from the disk before
74 auto attachStmt = db->CreateStatement("ATTACH DATABASE ? AS ?");
75 auto result = attachStmt->Prepare(mPath, mSnapshotDBName).Run();
76
77 if (!result.IsOk())
78 return;
79
81
82 auto blocksSource = mSnapshotDBName;
83
85 {
86 if (auto name = AttachOriginalDB(); !name.empty())
87 blocksSource = name;
88 }
89
90 // This would return and empty set when the project
91 // is detached
92 auto knownBlocks = CalculateKnownBlocks(blocksSource);
93
95 {
96 // We can assume, that if the known blocks are present,
97 // they come from the "original" database
98 SetupBlocksCopy(blocksSource, knownBlocks);
99 }
100 else if (knownBlocks.size() == mSnapshotInfo.Blocks.size())
101 {
102 auto syncInfo =
104
105 if (
106 syncInfo && syncInfo->SnapshotId == mSnapshotInfo.Id &&
107 syncInfo->SyncStatus == DBProjectData::SyncStatusSynced)
108 {
109 mCallback({ {}, 0, 0, true });
110 mNothingToDo = true;
111 return;
112 }
113 }
114
117
118 MarkProjectInDB(false);
119
121 mSnapshotInfo.Blocks.size() :
122 mSnapshotInfo.Blocks.size() - knownBlocks.size();
123
124 mRequests.reserve(1 + mMissingBlocks);
125
126 mRequests.push_back(std::make_pair(
128 [this](auto response) { OnProjectBlobDownloaded(response); }));
129
130 for (auto& block : mSnapshotInfo.Blocks)
131 {
132 if (knownBlocks.find(ToUpper(block.Hash)) != knownBlocks.end())
133 continue;
134
135 mRequests.push_back(std::make_pair(
136 block.Url, [this, hash = ToUpper(block.Hash)](auto response)
137 { OnBlockDownloaded(std::move(hash), response); }));
138 }
139
141 std::thread { &RemoteProjectSnapshot::RequestsThread, this };
142}
143
145{
146 DoCancel();
147
148 if (mRequestsThread.joinable())
149 mRequestsThread.join();
150
151 if (mCopyBlocksFuture.has_value())
152 mCopyBlocksFuture->wait();
153
154 {
155 auto lock = std::unique_lock { mResponsesMutex };
156 mResponsesEmptyCV.wait(lock, [this] { return mResponses.empty(); });
157 }
158
160
161 for (const auto& dbName : ListAttachedDatabases())
162 {
163 auto detachStmt = db->CreateStatement("DETACH DATABASE ?");
164 detachStmt->Prepare(dbName).Run();
165 }
166}
167
168std::shared_ptr<RemoteProjectSnapshot> RemoteProjectSnapshot::Sync(
169 ProjectInfo projectInfo, SnapshotInfo snapshotInfo, std::string path,
170 RemoteProjectSnapshotStateCallback callback, bool downloadDetached)
171{
172 auto snapshot = std::make_shared<RemoteProjectSnapshot>(
173 Tag {}, std::move(projectInfo), std::move(snapshotInfo), std::move(path),
174 std::move(callback), downloadDetached);
175
176 if (snapshot->mAttachedDBNames.empty())
177 {
178 snapshot->mCallback(
181 XO("Failed to attach to the Cloud project database")
182 .Translation()) },
183 0,
184 0,
185 false });
186
187 return {};
188 }
189
190 if (snapshot->mNothingToDo)
191 return {};
192
193 return snapshot;
194}
195
197{
198 DoCancel();
199
201 mDownloadedBlocks.load() + mCopiedBlocks.load(),
203 mProjectDownloaded.load() });
204}
205
207{
208 const auto duration =
209 mState.load(std::memory_order_acquire) == State::Downloading ?
210 Clock::now() - mStartTime :
212
213 return TransferStats {}
218 std::chrono::duration_cast<TransferStats::Duration>(duration));
219}
220
222{
223 return mProjectInfo.Id;
224}
225
227{
228 const std::string dbName = "o_" + mProjectInfo.Id;
229
230 const auto projectData =
232
233 if (!projectData)
234 return {};
235
237 // RemoteProjectSnapshot always receives a path to the database
238 // that has AudacityProject schema installed, even if it's a detached
239 // or was deleted from the disk before
240 auto attachStmt = db->CreateStatement("ATTACH DATABASE ? AS ?");
241 auto result = attachStmt->Prepare(projectData->LocalPath, dbName).Run();
242
243 if (!result.IsOk())
244 return {};
245
246 mAttachedDBNames.push_back(dbName);
247
248 return dbName;
249}
250
252 const std::string& dbName, std::unordered_set<std::string> blocks)
253{
254 // Still, better be safe than sorry
255 if (dbName == mSnapshotDBName)
256 return;
257
258 if (blocks.empty())
259 return;
260
261 mCopyBlocksFuture = std::async(
262 std::launch::async,
263 [this, dbName = dbName, blocks = std::move(blocks)]()
264 {
265 const auto queryString =
266 "INSERT INTO " + mSnapshotDBName +
267 ".sampleblocks "
268 "SELECT * FROM " +
269 dbName +
270 ".sampleblocks WHERE blockid IN (SELECT block_id FROM block_hashes WHERE hash = ?)";
271
272 // Only lock DB for one block a time so the download thread can
273 // continue to work
274 for (const auto& block : blocks)
275 {
276 if (!InProgress())
277 return false;
278
280
281 auto copyBlocksStatement = db->CreateStatement(queryString);
282
283 if (!copyBlocksStatement)
284 {
286 audacity::ToUTF8(copyBlocksStatement.GetError()
287 .GetErrorString()
288 .Translation()) });
289
290 return false;
291 }
292
293 auto result = copyBlocksStatement->Prepare(block).Run();
294
295 if (!result.IsOk())
296 {
298 audacity::ToUTF8(result.GetErrors()
299 .front()
300 .GetErrorString()
301 .Translation()) });
302 return false;
303 }
304
305 const auto rowsUpdated = result.GetModifiedRowsCount();
306 mCopiedBlocks.fetch_add(rowsUpdated, std::memory_order_acq_rel);
307
309 }
310
311 return true;
312 });
313}
314
315std::unordered_set<std::string> RemoteProjectSnapshot::CalculateKnownBlocks(
316 const std::string& attachedDbName) const
317{
318 std::unordered_set<std::string> remoteBlocks;
319
320 for (const auto& block : mSnapshotInfo.Blocks)
321 remoteBlocks.insert(ToUpper(block.Hash));
322
324
325 auto fn = db->CreateScalarFunction(
326 "inRemoteBlocks", [&remoteBlocks](const std::string& hash)
327 { return remoteBlocks.find(hash) != remoteBlocks.end(); });
328
329 auto statement = db->CreateStatement(
330 "SELECT hash FROM block_hashes WHERE project_id = ? AND inRemoteBlocks(hash) AND block_id IN (SELECT blockid FROM " +
331 attachedDbName + ".sampleblocks)");
332
333 if (!statement)
334 return {};
335
336 auto result = statement->Prepare(mProjectInfo.Id).Run();
337
338 std::unordered_set<std::string> knownBlocks;
339
340 for (auto row : result)
341 {
342 std::string hash;
343
344 if (!row.Get(0, hash))
345 continue;
346
347 knownBlocks.insert(hash);
348 }
349
350 return knownBlocks;
351}
352
354{
355 if (mState.load(std::memory_order_acquire) != State::Downloading)
356 return;
357
359
360 mRequestsCV.notify_one();
361
362 {
363 auto responsesLock = std::lock_guard { mResponsesMutex };
364 for (auto& response : mResponses)
365 response->abort();
366 }
367}
368
370 std::string url, SuccessHandler onSuccess, int retries)
371{
372 using namespace audacity::network_manager;
373
374 auto request = Request(url);
375
376 auto response = NetworkManager::GetInstance().doGet(request);
377
378 {
379 auto responsesLock = std::lock_guard { mResponsesMutex };
380 mResponses.push_back(response);
381 }
382
383 response->setRequestFinishedCallback(
384 [this, self = weak_from_this(), onSuccess = std::move(onSuccess), retries, response](auto)
385 {
386 auto strong = self.lock();
387 if(!strong)
388 return;
389
390 mDownloadedBytes.fetch_add(
391 response->getBytesAvailable(), std::memory_order_acq_rel);
392
393 RemoveResponse(response.get());
394
395 auto responseResult = GetResponseResult(*response, false);
396
397 if (responseResult.Code == SyncResultCode::Cancelled)
398 return;
399
400 if (
401 responseResult.Code != SyncResultCode::Success &&
402 responseResult.Code != SyncResultCode::ConnectionFailed)
403 {
404 OnFailure(std::move(responseResult));
405 return;
406 }
407
408 if (responseResult.Code == SyncResultCode::ConnectionFailed)
409 {
410 if (retries <= 0)
411 {
412 OnFailure(std::move(responseResult));
413 return;
414 }
415
417 response->getRequest().getURL(), std::move(onSuccess),
418 retries - 1);
419
420 return;
421 }
422
423 onSuccess(response);
424 });
425}
426
427namespace
428{
429std::vector<uint8_t>
431{
432 const auto size = response.getBytesAvailable();
433
434 if (size == 0)
435 return response.readAll<std::vector<uint8_t>>();
436
437 std::vector<uint8_t> data(size);
438 response.readData(data.data(), size);
439
440 return data;
441}
442} // namespace
443
444
445void RemoteProjectSnapshot::OnProjectBlobDownloaded(
447{
448 const std::vector<uint8_t> data = ReadResponseData(*response);
449 uint64_t dictSize = 0;
450
451 if (data.size() < sizeof(uint64_t))
452 {
453 OnFailure({ SyncResultCode::UnexpectedResponse, {} });
454 return;
455 }
456
457 std::memcpy(&dictSize, data.data(), sizeof(uint64_t));
458
459 if (!IsLittleEndian())
460 dictSize = SwapIntBytes(dictSize);
461
462 if (data.size() < sizeof(uint64_t) + dictSize)
463 {
464 OnFailure({ SyncResultCode::UnexpectedResponse, {} });
465 return;
466 }
467
468 auto db = CloudProjectsDatabase::Get().GetConnection();
469 auto transaction = db->BeginTransaction("p_" + mProjectInfo.Id);
470
471 auto updateProjectStatement = db->CreateStatement(
472 "INSERT INTO " + mSnapshotDBName +
473 ".project (id, dict, doc) VALUES (1, ?1, ?2) "
474 "ON CONFLICT(id) DO UPDATE SET dict = ?1, doc = ?2");
475
476 if (!updateProjectStatement)
477 {
479 audacity::ToUTF8(updateProjectStatement.GetError()
480 .GetErrorString()
481 .Translation()) });
482 return;
483 }
484
485 auto& preparedUpdateProjectStatement = updateProjectStatement->Prepare();
486
487 preparedUpdateProjectStatement.Bind(
488 1, data.data() + sizeof(uint64_t), dictSize, false);
489
490 preparedUpdateProjectStatement.Bind(
491 2, data.data() + sizeof(uint64_t) + dictSize,
492 data.size() - sizeof(uint64_t) - dictSize, false);
493
494 auto result = preparedUpdateProjectStatement.Run();
495
496 if (!result.IsOk())
497 {
498 OnFailure(
501 result.GetErrors().front().GetErrorString().Translation()) });
502
503 return;
504 }
505
506 auto deleteAutosaveStatement = db->CreateStatement(
507 "DELETE FROM " + mSnapshotDBName + ".autosave WHERE id = 1");
508
509 if (!deleteAutosaveStatement)
510 {
512 audacity::ToUTF8(deleteAutosaveStatement.GetError()
513 .GetErrorString()
514 .Translation()) });
515 return;
516 }
517
518 result = deleteAutosaveStatement->Prepare().Run();
519
520 if (!result.IsOk())
521 {
522 OnFailure(
525 result.GetErrors().front().GetErrorString().Translation()) });
526 return;
527 }
528
529 if (auto error = transaction.Commit(); error.IsError())
530 {
532 audacity::ToUTF8(error.GetErrorString().Translation()) });
533 return;
534 }
535
536 mProjectDownloaded.store(true, std::memory_order_release);
537 ReportProgress();
538}
539
540void RemoteProjectSnapshot::OnBlockDownloaded(
541 std::string blockHash, audacity::network_manager::ResponsePtr response)
542{
543 const auto compressedData = ReadResponseData(*response);
544
545 const auto blockData =
546 DecompressBlock(compressedData.data(), compressedData.size());
547
548 if (!blockData)
549 {
550 OnFailure(
552 audacity::ToUTF8(XO("Failed to decompress the Cloud project block")
553 .Translation()) });
554 return;
555 }
556
557 auto db = CloudProjectsDatabase::Get().GetConnection();
558 auto transaction = db->BeginTransaction("b_" + blockHash);
559
560 auto hashesStatement = db->CreateStatement(
561 "INSERT INTO block_hashes (project_id, block_id, hash) VALUES (?1, ?2, ?3) "
562 "ON CONFLICT(project_id, block_id) DO UPDATE SET hash = ?3");
563
564 auto result =
565 hashesStatement->Prepare(mProjectInfo.Id, blockData->BlockId, blockHash)
566 .Run();
567
568 if (!result.IsOk())
569 {
570 OnFailure(
573 result.GetErrors().front().GetErrorString().Translation()) });
574 return;
575 }
576
577 auto blockStatement = db->CreateStatement(
578 "INSERT INTO " + mSnapshotDBName +
579 ".sampleblocks (blockid, sampleformat, summin, summax, sumrms, summary256, summary64k, samples) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8) "
580 "ON CONFLICT(blockid) DO UPDATE SET sampleformat = ?2, summin = ?3, summax = ?4, sumrms = ?5, summary256 = ?6, summary64k = ?7, samples = ?8");
581
582 if (!blockStatement)
583 {
584 OnFailure(
587 blockStatement.GetError().GetErrorString().Translation()) });
588 return;
589 }
590
591 auto& preparedStatement = blockStatement->Prepare();
592
593 preparedStatement.Bind(1, blockData->BlockId);
594 preparedStatement.Bind(2, static_cast<int64_t>(blockData->Format));
595 preparedStatement.Bind(3, blockData->BlockMinMaxRMS.Min);
596 preparedStatement.Bind(4, blockData->BlockMinMaxRMS.Max);
597 preparedStatement.Bind(5, blockData->BlockMinMaxRMS.RMS);
598 preparedStatement.Bind(
599 6, blockData->Summary256.data(),
600 blockData->Summary256.size() * sizeof(MinMaxRMS), false);
601 preparedStatement.Bind(
602 7, blockData->Summary64k.data(),
603 blockData->Summary64k.size() * sizeof(MinMaxRMS), false);
604 preparedStatement.Bind(
605 8, blockData->Data.data(), blockData->Data.size(), false);
606
607 result = preparedStatement.Run();
608
609 if (!result.IsOk())
610 {
611 OnFailure(
614 result.GetErrors().front().GetErrorString().Translation()) });
615 return;
616 }
617
618 if (auto error = transaction.Commit(); error.IsError())
619 {
621 audacity::ToUTF8(error.GetErrorString().Translation()) });
622 return;
623 }
624
625 mDownloadedBlocks.fetch_add(1, std::memory_order_acq_rel);
626
627 ReportProgress();
628}
629
630void RemoteProjectSnapshot::OnFailure(ResponseResult result)
631{
632 SetState(State::Failed);
633 mCallback({ result,
634 mDownloadedBlocks.load(std::memory_order_acquire) +
635 mCopiedBlocks.load(std::memory_order_acquire),
636 mMissingBlocks,
637 mProjectDownloaded.load(std::memory_order_acquire) });
638}
639
640void RemoteProjectSnapshot::RemoveResponse(
642{
643 {
644 auto lock = std::lock_guard { mResponsesMutex };
645 mResponses.erase(
646 std::remove_if(
647 mResponses.begin(), mResponses.end(),
648 [response](auto& r) { return r.get() == response; }),
649 mResponses.end());
650
651 if (mResponses.empty())
652 mResponsesEmptyCV.notify_all();
653 }
654 {
655 auto lock = std::lock_guard { mRequestsMutex };
656 mRequestsInProgress--;
657 mRequestsCV.notify_one();
658 }
659}
660
661void RemoteProjectSnapshot::MarkProjectInDB(bool successfulDownload)
662{
663 if (mDownloadDetached)
664 return;
665
666 auto& db = CloudProjectsDatabase::Get();
667 auto currentData = db.GetProjectData(mProjectInfo.Id);
668
669 auto data = currentData ? *currentData : DBProjectData {};
670
671 data.ProjectId = mProjectInfo.Id;
672 data.SnapshotId = mSnapshotInfo.Id;
673 data.SyncStatus = successfulDownload ? DBProjectData::SyncStatusSynced :
674 DBProjectData::SyncStatusDownloading;
675 data.LastRead = wxDateTime::Now().GetTicks();
676 data.LocalPath = mPath;
677
678 if (data.SavesCount == 0)
679 data.SavesCount = 1;
680
681 // For the downloaded projects - we don't need to show the dialog
682 data.FirstSyncDialogShown = true;
683
684 db.UpdateProjectData(data);
685
686 if (successfulDownload)
687 db.SetProjectUserSlug(mProjectInfo.Id, mProjectInfo.Username);
688}
689
690void RemoteProjectSnapshot::ReportProgress()
691{
692 if (mState.load(std::memory_order_acquire) != State::Downloading)
693 return;
694
695 const auto projectDownloaded =
696 mProjectDownloaded.load(std::memory_order_acquire);
697 const auto blocksDownloaded =
698 mDownloadedBlocks.load(std::memory_order_acquire);
699
700 const auto blockCopied = mCopiedBlocks.load(std::memory_order_acquire);
701
702 const auto processedBlocks = blocksDownloaded + blockCopied;
703
704 const auto completed =
705 processedBlocks == mMissingBlocks && projectDownloaded;
706
707 if (completed)
708 {
709 CleanupOrphanBlocks();
710 SetState(State::Succeeded);
711 MarkProjectInDB(true);
712 }
713
714 mCallback({ {}, processedBlocks, mMissingBlocks, projectDownloaded });
715}
716
717bool RemoteProjectSnapshot::InProgress() const
718{
719 return mState.load(std::memory_order_acquire) == State::Downloading;
720}
721
722void RemoteProjectSnapshot::RequestsThread()
723{
724 constexpr auto MAX_CONCURRENT_REQUESTS = 6;
725
726 while (InProgress())
727 {
728 std::pair<std::string, SuccessHandler> request;
729
730 {
731 auto lock = std::unique_lock { mRequestsMutex };
732
733 if (mRequestsInProgress >= MAX_CONCURRENT_REQUESTS)
734 {
735 mRequestsCV.wait(
736 lock,
737 [this, MAX_CONCURRENT_REQUESTS] {
738 return mRequestsInProgress < MAX_CONCURRENT_REQUESTS ||
739 !InProgress();
740 });
741 }
742
743 if (!InProgress())
744 return;
745
746 if (mNextRequestIndex >= mRequests.size())
747 return;
748
749 request = mRequests[mNextRequestIndex++];
750 mRequestsInProgress++;
751 }
752
753 DownloadBlob(std::move(request.first), std::move(request.second), 3);
754
755 // TODO: Random sleep to avoid overloading the server
756 std::this_thread::sleep_for(std::chrono::milliseconds(50));
757 }
758}
759
760void RemoteProjectSnapshot::SetState(State state)
761{
762 if (state != State::Downloading)
763 mEndTime = Clock::now();
764
765 mState.exchange(state);
766}
767
769{
770 auto db = CloudProjectsDatabase::Get().GetConnection();
771
772 auto transaction = db->BeginTransaction("d_" + mProjectInfo.Id);
773
774 std::unordered_set<std::string> snaphotBlockHashes;
775
776 for (const auto& block : mSnapshotInfo.Blocks)
777 snaphotBlockHashes.insert(ToUpper(block.Hash));
778
779 auto inSnaphotFunction = db->CreateScalarFunction(
780 "inSnapshot", [&snaphotBlockHashes](const std::string& hash)
781 { return snaphotBlockHashes.find(hash) != snaphotBlockHashes.end(); });
782
783 // Delete blocks not in the snapshot
784 auto deleteBlocksStatement = db->CreateStatement(
785 "DELETE FROM " + mSnapshotDBName +
786 ".sampleblocks WHERE blockid NOT IN (SELECT block_id FROM block_hashes WHERE project_id = ? AND inSnapshot(hash))");
787
788 if (!deleteBlocksStatement)
789 return;
790
791 auto result = deleteBlocksStatement->Prepare(mProjectInfo.Id).Run();
792
793 if (!result.IsOk())
794 return;
795
796 auto deleteHashesStatement = db->CreateStatement(
797 "DELETE FROM block_hashes WHERE project_id = ? AND NOT inSnapshot(hash)");
798
799 if (!deleteHashesStatement)
800 return;
801
802 result = deleteHashesStatement->Prepare(mProjectInfo.Id).Run();
803
804 if (!result.IsOk())
805 return;
806
807 transaction.Commit();
808}
809
810bool RemoteProjectSnapshotState::IsComplete() const noexcept
811{
812 return (BlocksDownloaded == BlocksTotal && ProjectDownloaded) ||
814}
815
816} // namespace audacity::cloud::audiocom::sync
Declare functions to perform UTF-8 to std::wstring conversions.
struct State mState
XO("Cut/Copy/Paste")
Declare an interface for HTTP response.
constexpr IntType SwapIntBytes(IntType value) noexcept
Swap bytes in an integer.
Definition: MemoryX.h:377
bool IsLittleEndian() noexcept
Check that machine is little-endian.
Definition: MemoryX.h:368
Declare a class for performing HTTP requests.
Declare a class for constructing HTTP requests.
std::string ToUpper(const std::string &str)
Definition: StringUtils.cpp:46
wxString name
Definition: TagsEditor.cpp:166
static const auto fn
std::optional< DBProjectData > GetProjectData(std::string_view projectId) const
std::unordered_set< std::string > CalculateKnownBlocks(const std::string &attachedDbName) const
void DownloadBlob(std::string url, SuccessHandler onSuccess, int retries=3)
void RemoveResponse(audacity::network_manager::IResponse *response)
static std::shared_ptr< RemoteProjectSnapshot > Sync(ProjectInfo projectInfo, SnapshotInfo snapshotInfo, std::string path, RemoteProjectSnapshotStateCallback callback, bool downloadDetached)
RemoteProjectSnapshot(Tag, ProjectInfo projectInfo, SnapshotInfo snapshotInfo, std::string path, RemoteProjectSnapshotStateCallback callback, bool downloadDetached)
std::vector< std::shared_ptr< audacity::network_manager::IResponse > > mResponses
std::function< void(audacity::network_manager::ResponsePtr)> SuccessHandler
std::vector< std::pair< std::string, SuccessHandler > > mRequests
void SetupBlocksCopy(const std::string &dbName, std::unordered_set< std::string > blocks)
Interface, that provides access to the data from the HTTP response.
Definition: IResponse.h:113
virtual uint64_t getBytesAvailable() const noexcept=0
virtual uint64_t readData(void *buffer, uint64_t maxBytesCount)=0
ResponsePtr doGet(const Request &request)
Result< Statement > CreateStatement(std::string_view sql) const
Prepares the given SQL statement for execution.
Definition: Connection.cpp:253
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:202
std::vector< uint8_t > ReadResponseData(audacity::network_manager::IResponse &response)
std::optional< DecompressedBlock > DecompressBlock(const void *data, const std::size_t size)
std::function< void(RemoteProjectSnapshotState)> RemoteProjectSnapshotStateCallback
ResponseResult GetResponseResult(IResponse &response, bool readBody)
std::shared_ptr< IResponse > ResponsePtr
std::string ToUTF8(const std::wstring &wstr)
STL namespace.
Definition: Dither.cpp:67
TransferStats & SetBytesTransferred(int64_t bytesTransferred)
TransferStats & SetProjectFilesTransferred(int64_t projectFilesTransferred)
TransferStats & SetBlocksTransferred(int64_t blocksTransferred)
TransferStats & SetTransferDuration(Duration transferDuration)
std::vector< SnapshotBlockInfo > Blocks
Definition: CloudSyncDTO.h:89