!1374 启动定时器前重置数据量大小

Merge pull request !1374 from 张晟钰/master
This commit is contained in:
openharmony_ci 2024-11-16 07:09:56 +00:00 committed by Gitee
commit fa3075a53c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 28 additions and 1 deletions

View File

@ -550,6 +550,9 @@ private:
std::vector<std::string> GetSupportBackupBundleNames(vector<BJsonEntityCaps::BundleInfo> &bundleInfos,
bool isIncBackup);
void RefreshBundleDataSize(const vector<BJsonEntityCaps::BundleInfo> &newBundleInfos,
std::string bundleName, wptr<Service> ptr);
private:
static sptr<Service> instance_;
static std::mutex instanceLock_;

View File

@ -22,6 +22,7 @@
#include <cstdint>
#include <fcntl.h>
#include <inttypes.h>
#include <iomanip>
#include <sys/stat.h>
#include <sys/types.h>
@ -213,7 +214,8 @@ void Service::StartGetFdTask(std::string bundleName, wptr<Service> ptr)
int64_t lastTime = session->GetLastIncrementalTime(bundleName);
std::vector<BIncrementalData> bundleNames;
bundleNames.emplace_back(BIncrementalData {bundleName, lastTime});
BundleMgrAdapter::GetBundleInfosForIncremental(bundleNames, session->GetSessionUserId());
auto newBundleInfos = BundleMgrAdapter::GetBundleInfosForIncremental(bundleNames, session->GetSessionUserId());
RefreshBundleDataSize(newBundleInfos, bundleName, ptr);
string path = BConstants::GetSaBundleBackupRootDir(session->GetSessionUserId()).
append(bundleName).
append("/").
@ -233,6 +235,28 @@ void Service::StartGetFdTask(std::string bundleName, wptr<Service> ptr)
}
}
void Service::RefreshBundleDataSize(const vector<BJsonEntityCaps::BundleInfo> &newBundleInfos,
std::string bundleName, wptr<Service> ptr)
{
auto thisPtr = ptr.promote();
if (!thisPtr) {
HILOGE("this pointer is null");
return;
}
auto session = thisPtr->session_;
if (session == nullptr) {
HILOGE("session is nullptr");
return;
}
for (auto &info : newBundleInfos) {
if (info.name == bundleName) {
session->SetBundleDataSize(bundleName, info.increSpaceOccupied);
HILOGI("RefreshBundleDataSize, bundlename = %{public}s , datasize = %{public}" PRId64 "",
bundleName.c_str(), info.increSpaceOccupied);
}
}
}
ErrCode Service::GetAppLocalListAndDoIncrementalBackup()
{
HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__);