Don't delete the new file in openRead().
Although it may seems a left-over from a previous interrupted write, actually there are callers who call startWrite(), openRead() and then finishWrite(), and this was okay in the previous implementation, so we have to keep supporting it. The new file is virtually ignored in the new implementation, and we have no good way to know if it's actually a left-over or one that's being written, so simply leaving it there is also okay. Fixes: 157092639 Test: atest AppIdleHistoryTests#testFilesCreation Change-Id: I4dc7fde99d2b8e04356f082a6e6ad61c2835022e
This commit is contained in:
@@ -227,11 +227,8 @@ public class AtomicFile {
|
||||
}
|
||||
}
|
||||
|
||||
if (mNewName.exists()) {
|
||||
if (!mNewName.delete()) {
|
||||
Log.e(LOG_TAG, "Failed to delete outdated new file " + mNewName);
|
||||
}
|
||||
}
|
||||
// Don't delete mNewName here - it was okay to call openRead() between startWrite() and
|
||||
// finishWrite(), and we have to keep supporting it.
|
||||
return new FileInputStream(mBaseName);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user