Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up the unknown file list once the transfer is complete. #2570

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions sharing/nearby_connections_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -841,11 +841,13 @@ void NearbyConnectionsManagerImpl::OnPayloadTransferUpdate(
if (NearbyFlags::GetInstance().GetBoolFlag(
sharing::config_package_nearby::nearby_sharing_feature::
kDeleteUnexpectedReceivedFile)) {
// if we get kFile and have file_path, delete the file path.
// if we get a kFile type and have a file_path, delete the file path
// when transfer is failed. Add to the unknown file paths to delete list.
if (payload_it->second.content.type == PayloadContent::Type::kFile) {
auto file_path = payload_it->second.content.file_payload.file.path;
NL_LOG(WARNING) << __func__
<< ": Payload is Type::kFile type. Removing.";
NL_LOG(INFO) << __func__
<< ": Payload is Type::kFile type. Add the file path to "
"the unknown file paths to delete list.";
file_paths_to_delete_.insert(file_path);
}
}
Expand Down
14 changes: 12 additions & 2 deletions sharing/nearby_sharing_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3105,8 +3105,18 @@ void NearbySharingServiceImpl::OnIncomingTransferUpdate(
/* referrer_package=*/std::nullopt);

OnTransferComplete();
if (metadata.status() != TransferMetadata::Status::kComplete) {
// For any type of failure, lets make sure any pending files get cleaned
if (metadata.status() == TransferMetadata::Status::kComplete) {
if (NearbyFlags::GetInstance().GetBoolFlag(
config_package_nearby::nearby_sharing_feature::
kDeleteUnexpectedReceivedFile)) {
// When transfer is complete, let's make sure to clean up the unknown
// file paths list.
nearby_connections_manager_->ClearUnknownFilePathsToDelete();
NL_VLOG(1) << __func__
<< ": Transfer complete, clear unknown file paths.";
}
} else {
// For any type of failure, let's make sure any pending files get cleaned
// up.
RemoveIncomingPayloads(share_target);
}
Expand Down
Loading