Skip to content

Commit

Permalink
修复图片连接获取出错的提示
Browse files Browse the repository at this point in the history
修复档案下载下载路径格式错误的bug
  • Loading branch information
xiaojieonly committed Sep 12, 2024
1 parent 2efe989 commit b299237
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 47 deletions.
85 changes: 42 additions & 43 deletions app/src/main/java/com/hippo/ehviewer/spider/SpiderInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.hippo.ehviewer.spider;

import static com.hippo.ehviewer.spider.SpiderDen.getGalleryDownloadDir;
import static com.hippo.ehviewer.spider.SpiderQueen.SPIDER_INFO_BACKUP_FILENAME;
import static com.hippo.ehviewer.spider.SpiderQueen.SPIDER_INFO_FILENAME;

import android.content.Context;
Expand Down Expand Up @@ -269,48 +268,48 @@ public static SpiderInfo getSpiderInfo(GalleryInfo info) {
return null;
}

public static SpiderInfo createBackupSpiderInfo(GalleryInfo info) {
UniFile mDownloadDir = getGalleryDownloadDir(info);
if (mDownloadDir != null && mDownloadDir.isDirectory()) {
UniFile file = mDownloadDir.findFile(SPIDER_INFO_FILENAME);
if (file==null){
return null;
}
UniFile backupFile = mDownloadDir.findFile(SPIDER_INFO_BACKUP_FILENAME);
if (backupFile!=null){
backupFile.delete();
}
backupFile = mDownloadDir.createFile(SPIDER_INFO_BACKUP_FILENAME);
InputStream is;
OutputStream os = null;

try {
is = file.openInputStream();
os = backupFile.openOutputStream();

byte[] bytes = new byte[1024];
int l;
while((l=is.read(bytes))>0){
os.write(bytes,0,l);
}
os.flush();
IOUtils.closeQuietly(is);
SpiderInfo spiderInfo;
spiderInfo = SpiderInfo.read(file);
if (spiderInfo != null && spiderInfo.gid == info.gid &&
spiderInfo.token.equals(info.token)) {
return spiderInfo;
}
return null;
} catch (IOException e) {
return null;
} finally {
IOUtils.closeQuietly(os);
}

}
return null;
}
// public static SpiderInfo createBackupSpiderInfo(GalleryInfo info) {
// UniFile mDownloadDir = getGalleryDownloadDir(info);
// if (mDownloadDir != null && mDownloadDir.isDirectory()) {
// UniFile file = mDownloadDir.findFile(SPIDER_INFO_FILENAME);
// if (file==null){
// return null;
// }
// UniFile backupFile = mDownloadDir.findFile(SPIDER_INFO_BACKUP_FILENAME);
// if (backupFile!=null){
// backupFile.delete();
// }
// backupFile = mDownloadDir.createFile(SPIDER_INFO_BACKUP_FILENAME);
// InputStream is;
// OutputStream os = null;
//
// try {
// is = file.openInputStream();
// os = backupFile.openOutputStream();
//
// byte[] bytes = new byte[1024];
// int l;
// while((l=is.read(bytes))>0){
// os.write(bytes,0,l);
// }
// os.flush();
// IOUtils.closeQuietly(is);
// SpiderInfo spiderInfo;
// spiderInfo = SpiderInfo.read(file);
// if (spiderInfo != null && spiderInfo.gid == info.gid &&
// spiderInfo.token.equals(info.token)) {
// return spiderInfo;
// }
// return null;
// } catch (IOException e) {
// return null;
// } finally {
// IOUtils.closeQuietly(os);
// }
//
// }
// return null;
// }

public static SpiderInfo getSpiderInfo(GalleryDetail info) {
try {
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/java/com/hippo/ehviewer/spider/SpiderQueen.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public final class SpiderQueen implements Runnable {
public static final int STATE_FAILED = 3;
public static final int DECODE_THREAD_NUM = 2;
public static final String SPIDER_INFO_FILENAME = ".ehviewer";
// public static final String SPIDER_INFO_BACKUP_FILENAME = ".ehviewer_backup";

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

if (targetImageUrl == null) {
error = "TargetImageUrl error";
error = "GP不足/Insufficient GP";
break;
}
if (DEBUG_LOG) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ public void onSuccess(String downloadUrl) {
request.setTitle(galleryDetail.title);
request.setDescription(context.getString(R.string.download_archive_started));
request.setVisibleInDownloadsUi(true);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "/EhviewerArchiver/"+galleryDetail.title + ".zip");
// request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "EhviewerArchiver/"+galleryDetail.title + ".zip");
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "EhviewerArchiver/"+"[Abe Nattsu] SEX de Wakaru Unmei no Hito ~ Karada no Aishou... Tameshite miru? ~ Ch. 1-6 [Chinese] [裸單騎漢化]" + ".zip");
request.allowScanningByMediaScanner();

DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
Expand Down

0 comments on commit b299237

Please sign in to comment.