41 mHousekeepingOperation = std::async([
this] { PerformHousekeeping(); });
47 const auto now = std::chrono::system_clock::now();
51 auto projects = cloudProjectsDatabase.GetCloudProjects();
53 for (
const auto&
project : projects)
55 if (mHousekeepingCancelled.load())
60 if (!wxFileExists(path))
62 cloudProjectsDatabase.DeleteProject(
project.ProjectId);
66 const auto lastAccess =
69 const auto discardTreshold =
70 std::chrono::system_clock::from_time_t(lastAccess) + timeToKeep;
72 if (discardTreshold > now)
75 if (wxRemoveFile(path))
76 cloudProjectsDatabase.DeleteProject(
project.ProjectId);
84 mHousekeepingCancelled.store(
true);
85 if (mHousekeepingOperation.valid())
86 mHousekeepingOperation.wait();
90 auto connectionLock = cloudProjectsDatabase.GetConnection();
95 auto vacuumStatement = connectionLock->CreateStatement(
"VACUUM");
100 vacuumStatement->Prepare().Run();
104 std::atomic<bool> mHousekeepingCancelled {
false };
Declare functions to perform UTF-8 to std::wstring conversions.
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined */
static CloudProjectsDatabase & Get()
std::future< void > mHousekeepingOperation
void PerformHousekeeping()
void OnAppClosing(std::function< void()> callback)
void OnAppInitialized(std::function< void()> callback)
static Housekeeper housekeeper
IntSetting DaysToKeepFiles
wxString ToWXString(const std::string &str)