Revision a09587c7 F-Droid/src/org/fdroid/fdroid/net/AsyncDownloaderFromAndroid.java
F-Droid/src/org/fdroid/fdroid/net/AsyncDownloaderFromAndroid.java | ||
---|---|---|
10 | 10 |
import android.net.Uri; |
11 | 11 |
import android.os.Build; |
12 | 12 |
import android.os.ParcelFileDescriptor; |
13 |
import android.text.TextUtils; |
|
14 |
import android.util.Log; |
|
15 |
|
|
16 |
import org.fdroid.fdroid.Utils; |
|
13 | 17 |
|
14 | 18 |
import java.io.File; |
15 | 19 |
import java.io.FileDescriptor; |
... | ... | |
49 | 53 |
this.listener = listener; |
50 | 54 |
this.localFile = localFile; |
51 | 55 |
|
52 |
if (downloadTitle == null || downloadTitle.trim().length() == 0) {
|
|
56 |
if (TextUtils.isEmpty(downloadTitle)) {
|
|
53 | 57 |
this.downloadTitle = remoteAddress; |
54 | 58 |
} |
55 | 59 |
|
... | ... | |
97 | 101 |
* @throws IOException |
98 | 102 |
*/ |
99 | 103 |
private void copyFile(FileDescriptor inputFile, File outputFile) throws IOException { |
100 |
InputStream is = new FileInputStream(inputFile); |
|
101 |
OutputStream os = new FileOutputStream(outputFile); |
|
102 |
byte[] buffer = new byte[1024]; |
|
103 |
int count = 0; |
|
104 |
|
|
104 |
InputStream input = null; |
|
105 |
OutputStream output = null; |
|
105 | 106 |
try { |
106 |
while ((count = is.read(buffer, 0, buffer.length)) > 0) {
|
|
107 |
os.write(buffer, 0, count);
|
|
108 |
}
|
|
107 |
input = new FileInputStream(inputFile);
|
|
108 |
output = new FileOutputStream(outputFile);
|
|
109 |
Utils.copy(input, output);
|
|
109 | 110 |
} finally { |
110 |
os.close();
|
|
111 |
is.close();
|
|
111 |
Utils.closeQuietly(output);
|
|
112 |
Utils.closeQuietly(input);
|
|
112 | 113 |
} |
113 | 114 |
} |
114 | 115 |
|
Also available in: Unified diff