mirror of
https://gitee.com/openharmony/filemanagement_storage_service
synced 2024-11-27 01:01:16 +00:00
commit
005aa98640
@ -28,6 +28,10 @@ public:
|
||||
StorageRlMap() {}
|
||||
~StorageRlMap() {}
|
||||
V& operator[](const K& key)
|
||||
{
|
||||
return map_[key];
|
||||
}
|
||||
V ReadVal(const K& key)
|
||||
{
|
||||
Utils::UniqueWriteGuard<Utils::RWLock> mapGuard(this->rl_);
|
||||
return map_[key];
|
||||
|
@ -29,7 +29,7 @@ std::shared_ptr<Disk> DiskManagerService::GetDiskById(std::string diskId)
|
||||
if (!diskMap_.Contains(diskId)) {
|
||||
return nullptr;
|
||||
}
|
||||
return diskMap_[diskId];
|
||||
return diskMap_.ReadVal(diskId);
|
||||
}
|
||||
|
||||
void DiskManagerService::OnDiskCreated(Disk disk)
|
||||
@ -76,7 +76,7 @@ std::vector<Disk> DiskManagerService::GetAllDisks()
|
||||
int32_t DiskManagerService::GetDiskById(std::string diskId, Disk &disk)
|
||||
{
|
||||
if (diskMap_.Contains(diskId)) {
|
||||
disk = *diskMap_[diskId];
|
||||
disk = *diskMap_.ReadVal(diskId);
|
||||
return E_OK;
|
||||
}
|
||||
return E_NON_EXIST;
|
||||
|
@ -48,7 +48,7 @@ namespace StorageManager {
|
||||
LOGE("VolumeManagerService::OnVolumeDestroyed volumeId %{public}s not exists", volumeId.c_str());
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<VolumeExternal> volumePtr = volumeMap_[volumeId];
|
||||
std::shared_ptr<VolumeExternal> volumePtr = volumeMap_.ReadVal(volumeId);
|
||||
VolumeStateNotify(state, volumePtr);
|
||||
if (state == VolumeState::REMOVED || state == VolumeState::BAD_REMOVAL) {
|
||||
volumeMap_.Erase(volumeId);
|
||||
@ -62,7 +62,7 @@ namespace StorageManager {
|
||||
LOGE("VolumeManagerService::OnVolumeMounted volumeId %{public}s not exists", volumeId.c_str());
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<VolumeExternal> volumePtr = volumeMap_[volumeId];
|
||||
std::shared_ptr<VolumeExternal> volumePtr = volumeMap_.ReadVal(volumeId);
|
||||
volumePtr->SetFsType(fsType);
|
||||
volumePtr->SetFsUuid(fsUuid);
|
||||
volumePtr->SetPath(path);
|
||||
@ -90,7 +90,7 @@ namespace StorageManager {
|
||||
LOGE("VolumeManagerService::Mount volumeId %{public}s not exists", volumeId.c_str());
|
||||
return E_NON_EXIST;
|
||||
}
|
||||
std::shared_ptr<VolumeExternal> volumePtr = volumeMap_[volumeId];
|
||||
std::shared_ptr<VolumeExternal> volumePtr = volumeMap_.ReadVal(volumeId);
|
||||
if (volumePtr->GetState() != VolumeState::UNMOUNTED) {
|
||||
LOGE("VolumeManagerService::The type of volume(Id %{public}s) is not unmounted", volumeId.c_str());
|
||||
return E_MOUNT;
|
||||
@ -115,7 +115,7 @@ namespace StorageManager {
|
||||
LOGE("VolumeManagerService::Unmount volumeId %{public}s not exists", volumeId.c_str());
|
||||
return E_NON_EXIST;
|
||||
}
|
||||
std::shared_ptr<VolumeExternal> volumePtr = volumeMap_[volumeId];
|
||||
std::shared_ptr<VolumeExternal> volumePtr = volumeMap_.ReadVal(volumeId);
|
||||
if (volumePtr->GetState() != VolumeState::MOUNTED) {
|
||||
LOGE("VolumeManagerService::The type of volume(Id %{public}s) is not mounted", volumeId.c_str());
|
||||
return E_UMOUNT;
|
||||
@ -135,7 +135,7 @@ namespace StorageManager {
|
||||
|
||||
int32_t VolumeManagerService::Check(std::string volumeId)
|
||||
{
|
||||
std::shared_ptr<VolumeExternal> volumePtr = volumeMap_[volumeId];
|
||||
std::shared_ptr<VolumeExternal> volumePtr = volumeMap_.ReadVal(volumeId);
|
||||
std::shared_ptr<StorageDaemonCommunication> sdCommunication;
|
||||
sdCommunication = DelayedSingleton<StorageDaemonCommunication>::GetInstance();
|
||||
volumePtr->SetState(VolumeState::CHECKING);
|
||||
@ -181,7 +181,7 @@ namespace StorageManager {
|
||||
int32_t VolumeManagerService::GetVolumeById(std::string volumeId, VolumeExternal &vc)
|
||||
{
|
||||
if (volumeMap_.Contains(volumeId)) {
|
||||
vc = *volumeMap_[volumeId];
|
||||
vc = *volumeMap_.ReadVal(volumeId);
|
||||
return E_OK;
|
||||
}
|
||||
return E_NON_EXIST;
|
||||
@ -210,7 +210,7 @@ namespace StorageManager {
|
||||
if (volumeMap_.Find(volumeId) == volumeMap_.End()) {
|
||||
return E_NON_EXIST;
|
||||
}
|
||||
if (volumeMap_[volumeId]->GetState() != VolumeState::UNMOUNTED) {
|
||||
if (volumeMap_.ReadVal(volumeId)->GetState() != VolumeState::UNMOUNTED) {
|
||||
LOGE("VolumeManagerService::SetVolumeDescription volume state is not unmounted!");
|
||||
return E_VOL_STATE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user