Search in sources :

Example 1 with SingleMission

use of zlc.season.rxdownload2.entity.SingleMission in project RxDownload by ssseasonnn.

the class DownloadService method deleteDownload.

/**
     * Delete download.
     * <p>
     * Delete a url or all tasks belonging to missionId.
     *
     * @param url        url or missionId
     * @param deleteFile whether delete file
     */
public void deleteDownload(String url, boolean deleteFile) {
    DownloadMission mission = missionMap.get(url);
    if (mission != null && mission instanceof SingleMission) {
        mission.delete(dataBaseHelper, deleteFile);
        missionMap.remove(url);
    } else {
        createProcessor(url, processorMap).onNext(normal(null));
        if (deleteFile) {
            DownloadRecord record = dataBaseHelper.readSingleRecord(url);
            if (record != null) {
                deleteFiles(getFiles(record.getSaveName(), record.getSavePath()));
            }
        }
        dataBaseHelper.deleteRecord(url);
    }
}
Also used : SingleMission(zlc.season.rxdownload2.entity.SingleMission) DownloadMission(zlc.season.rxdownload2.entity.DownloadMission) DownloadRecord(zlc.season.rxdownload2.entity.DownloadRecord)

Aggregations

DownloadMission (zlc.season.rxdownload2.entity.DownloadMission)1 DownloadRecord (zlc.season.rxdownload2.entity.DownloadRecord)1 SingleMission (zlc.season.rxdownload2.entity.SingleMission)1