diff options
author | JP Abgrall <jpa@google.com> | 2014-03-07 17:31:25 -0800 |
---|---|---|
committer | JP Abgrall <jpa@google.com> | 2014-03-07 17:31:25 -0800 |
commit | 55b6c843a6166fbbf57aa4afba8b2c2b3e87cfea (patch) | |
tree | 3d5c3a181fe744a3db4bd1fe94d0fba1cd99358e /adb | |
parent | 4ce2f838e78592d0b93776b73ca4de855a423dde (diff) | |
download | core-55b6c843a6166fbbf57aa4afba8b2c2b3e87cfea.tar.gz core-55b6c843a6166fbbf57aa4afba8b2c2b3e87cfea.tar.bz2 core-55b6c843a6166fbbf57aa4afba8b2c2b3e87cfea.zip |
adb: Don't unlink special files on sync failure.
adb push some_disk_image /dev/block/mmcblk0p9
should not unlink the dev just because adb was ctrl-c'd.
Change-Id: I1b6669e8dba1f80fc1438b8deb618180b7e9a1b2
Signed-off-by: JP Abgrall <jpa@google.com>
Diffstat (limited to 'adb')
-rw-r--r-- | adb/file_sync_service.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/adb/file_sync_service.c b/adb/file_sync_service.c index 25bfdc983..1d80d26ac 100644 --- a/adb/file_sync_service.c +++ b/adb/file_sync_service.c @@ -172,7 +172,7 @@ static int fail_errno(int s) } static int handle_send_file(int s, char *path, uid_t uid, - gid_t gid, mode_t mode, char *buffer) + gid_t gid, mode_t mode, char *buffer, bool do_unlink) { syncmsg msg; unsigned int timestamp = 0; @@ -236,7 +236,7 @@ static int handle_send_file(int s, char *path, uid_t uid, if(writex(fd, buffer, len)) { int saved_errno = errno; adb_close(fd); - adb_unlink(path); + if (do_unlink) adb_unlink(path); fd = -1; errno = saved_errno; if(fail_errno(s)) return -1; @@ -261,7 +261,7 @@ static int handle_send_file(int s, char *path, uid_t uid, fail: if(fd >= 0) adb_close(fd); - adb_unlink(path); + if (do_unlink) adb_unlink(path); return -1; } @@ -323,6 +323,7 @@ static int do_send(int s, char *path, char *buffer) char *tmp; unsigned int mode; int is_link, ret; + bool do_unlink; tmp = strrchr(path,','); if(tmp) { @@ -339,10 +340,12 @@ static int do_send(int s, char *path, char *buffer) if(!tmp || errno) { mode = 0644; is_link = 0; + do_unlink = true; } else { struct stat st; /* Don't delete files before copying if they are not "regular" */ - if(lstat(path, &st) || S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) { + do_unlink = lstat(path, &st) || S_ISREG(st.st_mode) || S_ISLNK(st.st_mode); + if (do_unlink) { adb_unlink(path); } } @@ -369,7 +372,7 @@ static int do_send(int s, char *path, char *buffer) if (is_on_system(path)) { fs_config(tmp, 0, &uid, &gid, &mode, &cap); } - ret = handle_send_file(s, path, uid, gid, mode, buffer); + ret = handle_send_file(s, path, uid, gid, mode, buffer, do_unlink); } return ret; |