Skip to content

Commit

Permalink
update FileDownloadHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
wyouflf committed Oct 26, 2013
1 parent 32f3b22 commit 46c762d
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,10 @@
package com.lidroid.xutils.http.client.callback;

import android.text.TextUtils;

import com.lidroid.xutils.util.IOUtils;

import org.apache.http.HttpEntity;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;

public class FileDownloadHandler {

Expand Down Expand Up @@ -89,8 +83,10 @@ public File handleEntity(HttpEntity entity,

if (targetFile.exists() && !TextUtils.isEmpty(responseFileName)) {
File newFile = new File(targetFile.getParent(), responseFileName);
targetFile.renameTo(newFile);
return newFile;
while (newFile.exists()) {
newFile = new File(targetFile.getParent(), System.currentTimeMillis() + responseFileName);
}
return targetFile.renameTo(newFile) ? newFile : targetFile;
} else {
return targetFile;
}
Expand Down

0 comments on commit 46c762d

Please sign in to comment.