Code Monkey home page Code Monkey logo

tiercel's Issues

关于suspend和cancelByProducingResumeData的优缺点

我之前一般是使用suspend暂停,然后resume恢复。
如果出错调用了 didCompleteWithError,我再获取resumeData重新创建下载。
suspend 相比 cancelByProducingResumeData 有其他的什么坑吗,之前没遇到过。
suspend一般手动kill app 就会调用 didCompleteWithError。

疑问:是否可以后台下载任务完成后创建新的后台下载任务

问题1:下载的任务是大量小的且有依赖性的,例:A>B>C>D; 创建后台下载任务A,当A任务在后台完成下载后,是否可以创建新的后台下载任务B? (尝试这样做后发现新的后台下载任务B启动下载的时机不确定,不是立刻而是一段时间后)。
问题2:如果不可以后台下载完成后再创建新的后台任务,那么在前台时需要把所有的后台下载任务先创建出来,上限是多少?

考虑移除文件名前缀 `TR`

这种命名方式是 OC 语言风格的产物,Swift 中都是按模块划分的,移除更 swifty 。
使用时,已经有 tr 了,所以更不需要这样的命名风格。
建议考虑一下。

日期转换似乎有误

计算的下载完成时间比实际时间大了8小时
eg:实际 11:04 完成,计算获得时间为 19:04

看了下代码,似乎是转换时间时增加 3600 * 8 导致的,去掉后正常

public func convertTimeToDateString() -> String {
        // 此处为何要加 3600 * 8?
        let time = base + 3600 * 8
        let date = Date(timeIntervalSince1970: time)
        let formatter = DateFormatter()
        formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
        return formatter.string(from: date)
}

有循环引用,造成内存泄露

public class TRSessionDelegate: NSObject {
public weak var manager: TRManager?
}

此处是否应该用weak来修饰manager? 不然会造成循环引用,请追查一下。

下载总大小异常

下载demo查看下载功能,单个文件下载,将url替换成本地的,下载正常,但是task.progress.totalUnitCount = -1

fileExists 判断异常

Cache.swift

public func fileExists(fileName: String) -> Bool {
    guard let path = filePath(fileName: fileName) else { return false }
    return fileManager.fileExists(atPath: path)
}

这里判断文件用 fileExists 返回是true但文件打不开(下载的图片在File中显示为0B 且打不开但是显示下载成功)
建议用 isExecutableFile 判断

session.invalidateAndCancel() 问题

public var configuration = TRConfiguration() { didSet { guard !shouldCreatSession else { return } shouldCreatSession = true if status == .running { runningTasks = tasks.filter { $0.status == .running } waitingTasks = tasks.filter { $0.status == .waiting } totalSuspend() } else { session.invalidateAndCancel() } } }

对 configuration 赋值后,就没有机会创建新的 session,也就不能创建任务了吧

示例demo打包报错

您好 下载您的demo示例打包之后显示的错误为:
Undefined symbols for architecture armv7:
"protocol witness table for __ObjC.UIDevice : Tiercel.TiercelCompatible in Tiercel", referenced from:
Demo.BaseViewController.viewDidLoad() -> () in BaseViewController.o
"protocol witness table for Swift.Int64 : Tiercel.TiercelCompatible in Tiercel", referenced from:
function signature specialization <Arg[0] = Owned To Guaranteed> of Demo.ViewController1.(updateUI in _5C5E94575650EAFC2B93D94793CAD274)(Tiercel.TRTask) -> () in ViewController1.o
麻烦可以看一下吗?谢谢

New logo/icon proposal

Good day sir. I am a graphic designer and i am interested in designing a logo for your good project. I will be doing it as a gift for free. I just need your permission first before I begin my design. Hoping for your positive feedback. Thanks

能否考虑将manager中task的存储方式改为字典?

首先非常感谢大佬开源这个下载器源码。
看到源码中多处都是使用遍历匹配的方式来获取task,感觉换成字典性能应该会好很多。(强迫症)
或者说这样写是出于怎样的考虑呢?

success block里怎么获取文件本地地址?

如题 , 回调回来是 TRTask , 不能直接回来download task吗? 而且, success 不应该是下载成功的回调吗? 我看demo中, 还在success 里判断status? 其他任何状态都应该是 faild回调呀

arm64

真机提示这个错误
Undefined symbols for architecture arm64:
"protocol witness table for Swift.Int64 : Tiercel.TiercelCompatible in Tiercel", referenced from:
麻烦大佬看一下

when downloading crach ,this is the log

iPhone system - iOS10.3

moveItem error: Error Domain=NSCocoaErrorDomain Code=516 "“CFNetworkDownload_J1VtL6.tmp” couldn’t be moved to “OM

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x131d38b10 of class __NSCFBackgroundDownloadTask was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x1744344c0> (
<NSKeyValueObservance 0x174056b60: Observer: 0x131d07ab0, Key path: currentRequest, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x174653f50>

Xcode beta5,tr报错

Swift 4,Cocoapods 集成环境下

'tr' is inaccessible due to 'internal' protection level

arm64

打包出错:
Undefined symbols for architecture arm64:
"protocol witness table for Swift.Int64 : Tiercel.TiercelCompatible in Tiercel", referenced from:
大神这个不支持arm64吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.