Skip to content

Commit b882315

Browse files
committed
Manually delete cacheFile before we write to it
1 parent a2a1fd0 commit b882315

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Parse/src/main/java/com/parse/ParseFileController.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ public Task<File> then(Task<Void> task) throws Exception {
224224
return task.cast();
225225
}
226226

227+
// Since we give the cacheFile pointer to developers, it is not safe to guarantee
228+
// cacheFile always does not exist here, so it is better to delete it manually,
229+
// otherwise moveFile may throw an exception.
230+
ParseFileUtils.deleteQuietly(cacheFile);
227231
ParseFileUtils.moveFile(tempFile, cacheFile);
228232
return Task.forResult(cacheFile);
229233
}

0 commit comments

Comments
 (0)