Skip to content

Commit

Permalink
Fixes typos and style in ProjectCloudExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
crsib committed Mar 29, 2024
1 parent e4be773 commit 28b0fdc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
30 changes: 14 additions & 16 deletions libraries/lib-cloud-audiocom/sync/ProjectCloudExtension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct ProjectCloudExtension::CloudStatusChangedNotifier final :
std::swap(queue, Queue);
}

auto lock = std::lock_guard { OberverMutex };
auto lock = std::lock_guard { ObserverMutex };

for (const auto& [message, _] : queue)
Publish(message);
Expand All @@ -91,15 +91,15 @@ struct ProjectCloudExtension::CloudStatusChangedNotifier final :
Observer::Subscription
SubscribeSafe(std::function<void(const CloudStatusChangedMessage&)> callback)
{
auto lock = std::lock_guard { OberverMutex };
auto lock = std::lock_guard { ObserverMutex };
return Subscribe(std::move(callback));
}

using QueueType = std::vector<std::pair<CloudStatusChangedMessage, bool>>;

std::mutex QueueMutex;
QueueType Queue;
std::recursive_mutex OberverMutex;
std::recursive_mutex ObserverMutex;
};

ProjectCloudExtension::ProjectCloudExtension(AudacityProject& project)
Expand Down Expand Up @@ -212,12 +212,12 @@ void ProjectCloudExtension::OnSnapshotCreated(
const auto projectFilePath =
audacity::ToUTF8(ProjectFileIO::Get(mProject).GetFileName());

auto previosDbData = cloudDatabase.GetProjectDataForPath(projectFilePath);
auto previousDbData = cloudDatabase.GetProjectDataForPath(projectFilePath);

DBProjectData dbData;

if (previosDbData)
dbData = *previosDbData;
if (previousDbData)
dbData = *previousDbData;

dbData.ProjectId = response.Project.Id;
dbData.SnapshotId = response.Snapshot.Id;
Expand Down Expand Up @@ -302,13 +302,13 @@ void ProjectCloudExtension::OnSyncCompleted(
const auto projectFilePath =
audacity::ToUTF8(ProjectFileIO::Get(mProject).GetFileName());

auto previosDbData =
auto previousDbData =
cloudDatabase.GetProjectDataForPath(projectFilePath);

DBProjectData dbData;

if (previosDbData)
dbData = *previosDbData;
if (previousDbData)
dbData = *previousDbData;

const auto parentId = element->SnapshotResponse->Snapshot.ParentId;

Expand All @@ -317,7 +317,7 @@ void ProjectCloudExtension::OnSyncCompleted(
cloudDatabase.UpdateProjectData(dbData);

{
auto lock = std::lock_guard { mIdentifiersMutex };
auto lock = std::lock_guard { mIdentifiersMutex };
mSnapshotId = parentId;
}
}
Expand Down Expand Up @@ -370,9 +370,7 @@ void ProjectCloudExtension::CancelSync()

bool ProjectCloudExtension::IsSyncing() const
{
auto lock = std::lock_guard {
const_cast<ProjectCloudExtension*>(this)->mStatusMutex
};
auto lock = std::lock_guard { mStatusMutex };

return mLastStatus.Status == ProjectSyncStatus::Syncing;
}
Expand Down Expand Up @@ -558,12 +556,12 @@ void ProjectCloudExtension::MarkProjectSynced(bool success)
const auto projectFilePath =
audacity::ToUTF8(ProjectFileIO::Get(mProject).GetFileName());

auto previosDbData = cloudDatabase.GetProjectDataForPath(projectFilePath);
auto previousDbData = cloudDatabase.GetProjectDataForPath(projectFilePath);

DBProjectData dbData;

if (previosDbData)
dbData = *previosDbData;
if (previousDbData)
dbData = *previousDbData;

dbData.LastModified = wxDateTime::Now().GetTicks();
dbData.LastRead = dbData.LastModified;
Expand Down
2 changes: 1 addition & 1 deletion libraries/lib-cloud-audiocom/sync/ProjectCloudExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class CLOUD_AUDIOCOM_API ProjectCloudExtension final : public ClientData::Base
std::mutex mUploadQueueMutex;
std::vector<std::shared_ptr<UploadQueueElement>> mUploadQueue;

std::mutex mStatusMutex;
mutable std::mutex mStatusMutex;
CloudStatusChangedMessage mLastStatus;

std::unique_ptr<CloudStatusChangedNotifier> mAsyncStateNotifier;
Expand Down

0 comments on commit 28b0fdc

Please sign in to comment.