summaryrefslogtreecommitdiff
path: root/adb/file_sync_client.cpp
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2016-12-06 14:07:53 -0800
committerJosh Gao <jmgao@google.com>2016-12-12 16:47:34 -0800
commitaac1145a5bdcc25d3e4bb60ebbad8e2a5c94fc5e (patch)
tree9e4784a39f280e95d6a760f4d100425761faf652 /adb/file_sync_client.cpp
parentb0a15d83191c69f9a1279a09a40929b8b9fa6720 (diff)
adb: remove extraneous stat in sync_recv.
We do a remote stat to get the file's size before pulling in sync_recv, but all of the callers to sync_recv have already done a stat. Pass the expected file size into sync_recv to remove its stat. Bug: http://b/31289465 Test: python test_device.py Change-Id: I7ca8ed11c6134e5954acac86626f880ade3ec696
Diffstat (limited to 'adb/file_sync_client.cpp')
-rw-r--r--adb/file_sync_client.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/adb/file_sync_client.cpp b/adb/file_sync_client.cpp
index 76119efc40..271943d312 100644
--- a/adb/file_sync_client.cpp
+++ b/adb/file_sync_client.cpp
@@ -720,13 +720,7 @@ static bool sync_send(SyncConnection& sc, const char* lpath, const char* rpath,
}
static bool sync_recv(SyncConnection& sc, const char* rpath, const char* lpath,
- const char* name=nullptr) {
- struct stat st;
- if (!sync_stat_fallback(sc, rpath, &st)) {
- sc.Error("stat failed when trying to receive %s: %s", rpath, strerror(errno));
- return false;
- }
-
+ const char* name, uint64_t expected_size) {
if (!sc.SendRequest(ID_RECV, rpath)) return false;
adb_unlink(lpath);
@@ -778,7 +772,7 @@ static bool sync_recv(SyncConnection& sc, const char* rpath, const char* lpath,
bytes_copied += msg.data.size;
sc.RecordBytesTransferred(msg.data.size);
- sc.ReportProgress(name != nullptr ? name : rpath, bytes_copied, st.st_size);
+ sc.ReportProgress(name != nullptr ? name : rpath, bytes_copied, expected_size);
}
sc.RecordFilesTransferred(1);
@@ -1121,7 +1115,7 @@ static bool copy_remote_dir_local(SyncConnection& sc, std::string rpath,
continue;
}
- if (!sync_recv(sc, ci.rpath.c_str(), ci.lpath.c_str())) {
+ if (!sync_recv(sc, ci.rpath.c_str(), ci.lpath.c_str(), nullptr, ci.size)) {
return false;
}
@@ -1232,7 +1226,7 @@ bool do_sync_pull(const std::vector<const char*>& srcs, const char* dst,
sc.NewTransfer();
sc.SetExpectedTotalBytes(src_st.st_size);
- if (!sync_recv(sc, src_path, dst_path, name)) {
+ if (!sync_recv(sc, src_path, dst_path, name, src_st.st_size)) {
success = false;
continue;
}