Skip to content

Commit b51b10d

Browse files
committed
修复了由画廊名称中的"/"字符引起的档案下载路径不正常的问题
1 parent 7f88a66 commit b51b10d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

app/src/main/java/com/hippo/ehviewer/ui/dialog/ArchiverDownloadDialog.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ public void onSuccess(String downloadUrl) {
204204
body.setVisibility(View.VISIBLE);
205205
dialog.dismiss();
206206
showTip(R.string.download_archive_started, LENGTH_SHORT);
207+
String fileName = galleryDetail.title.replaceAll("/","");
207208
Uri downloadUri = Uri.parse(downloadUrl);
208209
DownloadManager.Request request = new DownloadManager.Request(downloadUri);
209210
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE | DownloadManager.Request.NETWORK_WIFI);
@@ -212,7 +213,7 @@ public void onSuccess(String downloadUrl) {
212213
request.setTitle(galleryDetail.title);
213214
request.setDescription(context.getString(R.string.download_archive_started));
214215
request.setVisibleInDownloadsUi(true);
215-
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, ARCHIVER_PATH+galleryDetail.title + ".zip");
216+
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, ARCHIVER_PATH+fileName + ".zip");
216217
request.allowScanningByMediaScanner();
217218

218219
DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
@@ -312,7 +313,8 @@ private void unzipAndImportFile(Cursor cursor) throws IllegalArgumentException,
312313
return;
313314
}
314315
long downloadId = cursor.getLong(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_ID));
315-
String tempFilePath = tempDir.getPath() + "/" + galleryDetail.title;
316+
String fileName = galleryDetail.title.replaceAll("/","");
317+
String tempFilePath = tempDir.getPath() + "/" + fileName;
316318
String zipFilePath = zipFile.getPath();
317319
new Thread(() -> {
318320
boolean result = GZIPUtils.UnZipFolder(zipFilePath, tempFilePath);

0 commit comments

Comments
 (0)