From 77f156d9f0e683d4d1cf5e1e4327c39d73c9247c Mon Sep 17 00:00:00 2001 From: Henrik Baard Date: Thu, 17 Dec 2015 13:58:42 +0100 Subject: [PATCH] Failing to "Migrate data" leaves target unusable When "migrating" data failes due to insufficient space at target location, the data copied so far is left in target location, which in practice is now filled to the brim. If copy fails clean up the data copied so far since user has the data in original location. Bug: 26322200 Change-Id: Iab29a7f9e653e6857ee0e2723d151dfec81b14dd --- MoveTask.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MoveTask.cpp b/MoveTask.cpp index a8fe14d..a0522d2 100644 --- a/MoveTask.cpp +++ b/MoveTask.cpp @@ -198,7 +198,7 @@ void MoveTask::run() { // Step 3: perform actual copy if (execCp(fromPath, toPath, 20, 60) != OK) { - goto fail; + goto copy_fail; } // NOTE: MountService watches for this magic value to know @@ -218,6 +218,12 @@ void MoveTask::run() { notifyProgress(kMoveSucceeded); release_wake_lock(kWakeLock); return; + +copy_fail: + // if we failed to copy the data we should not leave it laying around + // in target location. Do not check return value, we can not do any + // useful anyway. + execRm(toPath, 80, 1); fail: { std::lock_guard lock(VolumeManager::Instance()->getLock());