Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5911442c authored by d34d's avatar d34d Committed by Clark Scheff
Browse files

Delete destination file when copy fails

Change-Id: Ic398a2eaa7ac06d8c2ffccc10033d2d32a0dba60
(cherry picked from commit 766c7ba6)
(cherry picked from commit b2dfe80d)
parent 9a92b04c
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1176,6 +1176,13 @@ public final class FileHelper {
            Log.e(TAG,
                    String.format(TAG, "Failed to copy from %s to %d", src, dst), e); //$NON-NLS-1$

            try {
                // delete the destination file if it exists since the operation failed
                if (dst.exists()) {
                    dst.delete();
                }
            } catch (Throwable t) {/**NON BLOCK**/}

            // Check if this error is an out of space exception and throw that specifically.
            // ENOSPC -> Error No Space
            if (e.getCause() instanceof ErrnoException