From 00e1c3e3d4aff84cfca6f4f3276a451fa107e770 Mon Sep 17 00:00:00 2001 From: tickstep Date: Wed, 2 Nov 2022 21:52:11 +0800 Subject: [PATCH] fix illegal download file issue #183 --- internal/file/downloader/downloader.go | 3 ++- internal/syncdrive/file_action_task.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/file/downloader/downloader.go b/internal/file/downloader/downloader.go index e6ff350..f510c4a 100644 --- a/internal/file/downloader/downloader.go +++ b/internal/file/downloader/downloader.go @@ -28,6 +28,7 @@ import ( "github.com/tickstep/library-go/requester/rio/speeds" "io" "net/http" + "strings" "sync" "time" ) @@ -388,7 +389,7 @@ func (der *Downloader) Execute() error { cmdutil.Trigger(der.onCancelEvent) return apierr } - if durl == nil || durl.Url == "" || durl.Url == aliyunpan.IllegalDownloadUrl { + if durl == nil || durl.Url == "" || strings.HasPrefix(durl.Url, aliyunpan.IllegalDownloadUrlPrefix) { logger.Verbosef("无法获取有效的下载链接: %+v\n", durl) cmdutil.Trigger(der.onCancelEvent) der.removeInstanceState() // 移除断点续传文件 diff --git a/internal/syncdrive/file_action_task.go b/internal/syncdrive/file_action_task.go index eb25d73..04cc9d9 100644 --- a/internal/syncdrive/file_action_task.go +++ b/internal/syncdrive/file_action_task.go @@ -227,7 +227,7 @@ func (f *FileActionTask) downloadFile(ctx context.Context) error { f.syncFileDb.Update(f.syncItem) return fmt.Errorf("无法获取有效的下载链接") } - if durl.Url == aliyunpan.IllegalDownloadUrl { + if strings.HasPrefix(durl.Url, aliyunpan.IllegalDownloadUrlPrefix) { logger.Verbosef("无法获取有效的下载链接: %+v\n", durl) f.syncItem.Status = SyncFileStatusIllegal f.syncItem.StatusUpdateTime = utils.NowTimeStr()