Skip to content

Commit 29a3795

Browse files
committed
Merge pull request #120 from ParsePlatform/wangmengyan.t8184922_ParseFileController_delete_cache_file_before_move_temp_file
Manually delete cacheFile before we write to it
2 parents ed75e68 + b882315 commit 29a3795

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)