Skip to content

Commit b299237

Browse files
committed
修复图片连接获取出错的提示
修复档案下载下载路径格式错误的bug
1 parent 2efe989 commit b299237

File tree

3 files changed

+46
-47
lines changed

3 files changed

+46
-47
lines changed

app/src/main/java/com/hippo/ehviewer/spider/SpiderInfo.java

+42-43
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.hippo.ehviewer.spider;
1818

1919
import static com.hippo.ehviewer.spider.SpiderDen.getGalleryDownloadDir;
20-
import static com.hippo.ehviewer.spider.SpiderQueen.SPIDER_INFO_BACKUP_FILENAME;
2120
import static com.hippo.ehviewer.spider.SpiderQueen.SPIDER_INFO_FILENAME;
2221

2322
import android.content.Context;
@@ -269,48 +268,48 @@ public static SpiderInfo getSpiderInfo(GalleryInfo info) {
269268
return null;
270269
}
271270

272-
public static SpiderInfo createBackupSpiderInfo(GalleryInfo info) {
273-
UniFile mDownloadDir = getGalleryDownloadDir(info);
274-
if (mDownloadDir != null && mDownloadDir.isDirectory()) {
275-
UniFile file = mDownloadDir.findFile(SPIDER_INFO_FILENAME);
276-
if (file==null){
277-
return null;
278-
}
279-
UniFile backupFile = mDownloadDir.findFile(SPIDER_INFO_BACKUP_FILENAME);
280-
if (backupFile!=null){
281-
backupFile.delete();
282-
}
283-
backupFile = mDownloadDir.createFile(SPIDER_INFO_BACKUP_FILENAME);
284-
InputStream is;
285-
OutputStream os = null;
286-
287-
try {
288-
is = file.openInputStream();
289-
os = backupFile.openOutputStream();
290-
291-
byte[] bytes = new byte[1024];
292-
int l;
293-
while((l=is.read(bytes))>0){
294-
os.write(bytes,0,l);
295-
}
296-
os.flush();
297-
IOUtils.closeQuietly(is);
298-
SpiderInfo spiderInfo;
299-
spiderInfo = SpiderInfo.read(file);
300-
if (spiderInfo != null && spiderInfo.gid == info.gid &&
301-
spiderInfo.token.equals(info.token)) {
302-
return spiderInfo;
303-
}
304-
return null;
305-
} catch (IOException e) {
306-
return null;
307-
} finally {
308-
IOUtils.closeQuietly(os);
309-
}
310-
311-
}
312-
return null;
313-
}
271+
// public static SpiderInfo createBackupSpiderInfo(GalleryInfo info) {
272+
// UniFile mDownloadDir = getGalleryDownloadDir(info);
273+
// if (mDownloadDir != null && mDownloadDir.isDirectory()) {
274+
// UniFile file = mDownloadDir.findFile(SPIDER_INFO_FILENAME);
275+
// if (file==null){
276+
// return null;
277+
// }
278+
// UniFile backupFile = mDownloadDir.findFile(SPIDER_INFO_BACKUP_FILENAME);
279+
// if (backupFile!=null){
280+
// backupFile.delete();
281+
// }
282+
// backupFile = mDownloadDir.createFile(SPIDER_INFO_BACKUP_FILENAME);
283+
// InputStream is;
284+
// OutputStream os = null;
285+
//
286+
// try {
287+
// is = file.openInputStream();
288+
// os = backupFile.openOutputStream();
289+
//
290+
// byte[] bytes = new byte[1024];
291+
// int l;
292+
// while((l=is.read(bytes))>0){
293+
// os.write(bytes,0,l);
294+
// }
295+
// os.flush();
296+
// IOUtils.closeQuietly(is);
297+
// SpiderInfo spiderInfo;
298+
// spiderInfo = SpiderInfo.read(file);
299+
// if (spiderInfo != null && spiderInfo.gid == info.gid &&
300+
// spiderInfo.token.equals(info.token)) {
301+
// return spiderInfo;
302+
// }
303+
// return null;
304+
// } catch (IOException e) {
305+
// return null;
306+
// } finally {
307+
// IOUtils.closeQuietly(os);
308+
// }
309+
//
310+
// }
311+
// return null;
312+
// }
314313

315314
public static SpiderInfo getSpiderInfo(GalleryDetail info) {
316315
try {

app/src/main/java/com/hippo/ehviewer/spider/SpiderQueen.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ public final class SpiderQueen implements Runnable {
107107
public static final int STATE_FAILED = 3;
108108
public static final int DECODE_THREAD_NUM = 2;
109109
public static final String SPIDER_INFO_FILENAME = ".ehviewer";
110-
// public static final String SPIDER_INFO_BACKUP_FILENAME = ".ehviewer_backup";
111110

112111
public static final String SPIDER_INFO_BACKUP_DIR = "backupDir";
113112
private static final String TAG = SpiderQueen.class.getSimpleName();
@@ -1311,7 +1310,7 @@ private boolean downloadImage(long gid, int index, String pToken, String previou
13111310
response = call.execute();
13121311
targetImageUrl = response.header("location");
13131312
} catch (IOException e) {
1314-
error = "TargetImageUrl error";
1313+
error = "GP不足/Insufficient GP";
13151314
IOException ioException = new IOException("原图链接获取失败", e);
13161315
FirebaseCrashlytics.getInstance().recordException(ioException);
13171316
break;
@@ -1321,7 +1320,7 @@ private boolean downloadImage(long gid, int index, String pToken, String previou
13211320
}
13221321

13231322
if (targetImageUrl == null) {
1324-
error = "TargetImageUrl error";
1323+
error = "GP不足/Insufficient GP";
13251324
break;
13261325
}
13271326
if (DEBUG_LOG) {

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ public void onSuccess(String downloadUrl) {
210210
request.setTitle(galleryDetail.title);
211211
request.setDescription(context.getString(R.string.download_archive_started));
212212
request.setVisibleInDownloadsUi(true);
213-
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "/EhviewerArchiver/"+galleryDetail.title + ".zip");
213+
// request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "EhviewerArchiver/"+galleryDetail.title + ".zip");
214+
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "EhviewerArchiver/"+"[Abe Nattsu] SEX de Wakaru Unmei no Hito ~ Karada no Aishou... Tameshite miru? ~ Ch. 1-6 [Chinese] [裸單騎漢化]" + ".zip");
214215
request.allowScanningByMediaScanner();
215216

216217
DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);

0 commit comments

Comments
 (0)